Click here to Skip to main content
15,884,979 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have created an application that runs in background. when i minimize it, it will appear on the task bar. it is working fine, but when i turn off my computer, windows says that my application is blocking the shut down process. how do i close my application when i shut down my computer?
i developed it using vs2013 and published it on windows XP computer.

What I have tried:

finding answer over the internet, this is my first time to encouter this.
Posted
Updated 2-Aug-16 22:01pm
v2
Comments
Ralf Meier 2-Aug-16 6:49am    
OK ... tell us something more about your application.
How do you finish it normally ?
Are there any Threads, Tasks or Backgroundworkers in this application ?
ProgrammingEnthusiast 2-Aug-16 20:50pm    
i used threads and background worker on it. there's also a timer

There are certain talks (messages) between the Os and your application while OS try to shut down...
OS actually sent a WM_QUERYENDSESSION to your application, but as you didn't handled it it got a false response, marking your application as blocking...
Read this paper, to see how prepare your application to properly play during shut down process:
Guidelines for Applications (Windows)[^]
 
Share this answer
 
i have already resolved it by adding this code during form_closing event of my main form.
If e.CloseReason = CloseReason.WindowsShutDown Then Me.Dispose
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900