Home All Groups Group Topic Archive Search About

OnSessionEnding(object sender, SessionEndingEventArgs e) fails

Author
10 Mar 2005 8:33 PM
Waqar

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
Author
10 Mar 2005 9:09 PM
Afaq
Pleasze review
http://www.dotnet247.com/247reference/msgs/14/74770.aspx

Same dission, but OnSessionEnding( fails to notify about shutdown.

Regards,
Afaq



Show quoteHide quote
"Waqar" wrote:

> 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
>
>

Bookmark and Share