DateTime - Misusing Greater Than?

  • Thread starter Luc The Perverse
  • Start date
L

Luc The Perverse

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;

}
}
}
 
P

Peter Duniho

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
 
L

Luc The Perverse

Peter said:
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
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 :) ).

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top