By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,668 Members | 1,716 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,668 IT Pros & Developers. It's quick & easy.

OnSessionEnding(object sender, SessionEndingEventArgs e) fails

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Please review,

http://www.dotnet247.com/247referenc.../14/74770.aspx
OnSessionEnding( does not work, there is some problem ??
Regards

"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

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.