I have a C# program in 2003 that creates a reminder bubble (windows form) to remind a user to pick up their printout. The bubbles show up fine, and they have 2 buttons, a yes and a snooze. The yes resynchs the thread. The snooze puts the bubble to sleep for 5 minutes.
Originally my event handler code for the snooze button pointed to the following method:
This worked fine, except that if a bubble was snoozed and the user tried to shut down the computer, the shutdown would abort trying to close my program, and wouldn't allow a logoff/out until the bubble was resynched at which time the shutdown happened as expected. I assume the reason is the AutoEventReset object (ThreadControll er) and the wait command not releasing. the closing event doesn't fire during the windows shutdown process so I could not release the thread wait that way.
So I decided I would try a timer on the form, which would make sure the bubble had no issues being closed during shutdown, except that it seems the form must be visible when using the timer, as when I modified the code to use the timer, the timer would be enabled and the form would be invisible, but once the end of the method hit, the form would pop up visible again.
So any idea which method is better for this situation, and if so what am I doing wrong to get these bubbles to snooze and hide properly, and allow windows to shut them down? Thanks a bunch.
Originally my event handler code for the snooze button pointed to the following method:
Code:
public void SnoozeForm(int minutes) { //VAR TimeSpan waitLength = DateTime.Now.AddMinutes(minutes) - DateTime.Now; //BEGIN //Hide the form this.Hide(); //Tell threader this bubble is hidden again this.myThreader.BubblesVisible--; //Turn on Context Menu if no more visible bubbles if(this.myThreader.BubblesVisible == 0) { this.myThreader.frmEOD.FlipContextMenu(true); }//end if //Suspend Thread for endTime this.ThreadController.WaitOne(waitLength, false); //Check to see if we were awoken because of end of day if(!this.myThreader.EndOfDay) { //Turn off context menu this.myThreader.frmEOD.FlipContextMenu(false); //Tell threader we are visible this.myThreader.BubblesVisible++; //Once time has expired unhide the form if(!this.Visible) { this.Show(); }//end if } else if(this.myThreader.AboutOn) { SnoozeForm(5); } else { //Resynch Thread ResynchThread(true); } }//SnoozeForm
So I decided I would try a timer on the form, which would make sure the bubble had no issues being closed during shutdown, except that it seems the form must be visible when using the timer, as when I modified the code to use the timer, the timer would be enabled and the form would be invisible, but once the end of the method hit, the form would pop up visible again.
So any idea which method is better for this situation, and if so what am I doing wrong to get these bubbles to snooze and hide properly, and allow windows to shut them down? Thanks a bunch.
Comment