C# Sharp Windows Application prevents Windows from shutting down / logging off

Posted by user299711 on Stack Overflow See other posts from Stack Overflow or by user299711
Published on 2010-03-23T08:27:48Z Indexed on 2010/03/23 8:33 UTC
Read the original article Hit count: 355

Filed under:
|
|
|
|

I have written a C# Windows Forms application, not a service (it is only used when the user is logged in and has a graphical user interface) that has a background thread running in an infinite loop.

When I try shutting down Windows (7) however, it tells me the program is preventing it from shutting down or logging off and asks me whether I want to force a shutdown.

Now, is there any possibility for my program to become aware (get a handler) of Windows trying to quit it or to log off?

So, what I need is to make the application realize when Windows tries to quit.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Windows