OnSessionEnding(object sender, SessionEndingEventArgs e) fails

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

I have a windows form that when it closes it simply hides itself in
combination for a notify icon to reactivate it again - like Microsoft
messenger. You have to specifically exit the application by right clicking
on the NotifyIcon and selecting Exit from it's context menu.

I'm overriding the OnClosing event, hiding the form, and setting the
CancelEventArgs.Cancel to true so that the app is not closed but instead
remains alive on the system tray (NotifyIcon). But this causes a problem
when you shutdown Windows, the OnClosing is overridden by my code since I
can tell the difference between the user pressing the X to close the window
or Windows closing it for a system shutdown. So when this application is
running, the system will not shut down until you manually close this
application - which I don't need to tell you how frustrating that is to
users.

Some body will sure suggest me to use

public void OnSessionEnding(object sender, SessionEndingEventArgs e)

to control the shutdownevent and close the window in that.

But this event is not working properly. Can any body can give me some lights
over this issuse.

what i need is a code sample or references to matterial about it.

Looking for a working sample if possible.

Thanks.

Regards,
Waqar
 
Back
Top