Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

DateTime - Misusing Greater Than?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luc The Perverse - 05 Jan 2008 01:41 GMT
I was trying to make a quick 5 minute app to remind me to do something
before leaving work - just have the dialog appear which showed in the
quicklaunch bar.

The application hung (which was unfortunate as I had set it as a startup
and had some difficulty deleting the link with the CPU at 100%)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Warn5 {
    public partial class Form1 : Form {
        DateTime p = new DateTime(2008, 1, 1, 17, 0, 0);
        public Form1() {
            InitializeComponent();
            while (DateTime.Now > p)
                p.AddDays(1);
        }

        private void timer1_Tick(object sender, EventArgs e) {
            if (DateTime.Now > p) {
                this.WindowState = FormWindowState.Normal;
                this.BringToFront();
                while (DateTime.Now > p)
                    p.AddDays(1);
            }
        }

        private void notifyIcon1_MouseDoubleClick(object sender,
MouseEventArgs e) {
            this.WindowState = FormWindowState.Normal;

        }
    }
}

--
Alex Taylor
Peter Duniho - 05 Jan 2008 02:22 GMT
> I was trying to make a quick 5 minute app to remind me to do something  
> before leaving work - just have the dialog appear which showed in the  
> quicklaunch bar.
>
> The application hung (which was unfortunate as I had set it as a startup  
> and had some difficulty deleting the link with the CPU at 100%)

Instead of "p.AddDays(1)", try "p = p.AddDays(1)".

Also, next time you've got a process hogging the CPU, a fast way to get  
control back is to bring up the Task Manager (Ctrl-Shift-Esc) and  
right-click on the process so that you can lower the priority and/or kill  
the process.  Task Manager is reasonably lightweight and you can often  
control the process externally faster than you can get the process itself  
to respond (especially if your process is stuck in a loop preventing it  
from actually processing any events :) ).

Pete
Luc The Perverse - 05 Jan 2008 05:40 GMT
>> I was trying to make a quick 5 minute app to remind me to do something
>> before leaving work - just have the dialog appear which showed in the
[quoted text clipped - 4 lines]
>
> Instead of "p.AddDays(1)", try "p = p.AddDays(1)".

LOL.  Why - in retrospect, I suppose that does make a little sense :)

> Also, next time you've got a process hogging the CPU, a fast way to get
> control back is to bring up the Task Manager (Ctrl-Shift-Esc) and
[quoted text clipped - 3 lines]
> itself to respond (especially if your process is stuck in a loop
> preventing it from actually processing any events :) ).

Hmmm - COOL. I haven't known how to get to it directly since I switched
to XP Pro - I was so used to pushing Ctrl Alt Delete and then clicking
task manager (or whatever it is.)

Thank you very much sir!

--
LTP

:)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.