Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added a procedure for termination action for some parallel running applications and deletion of some used files by main application to be shutdown safely when main application ends up. problem is that sometimes main application terminates due to some unexpected exceptions and sometimes it seems to be ended but it just disappears and run some where may be in background which cause other applications running and let remain used files in open state. That's why I need to create a service which monitor existence of this running application.

Now what will be the windows state of such unexpectedly disappeared application? also how can i perform deletion action on such files which are still open and used by another process and thus may cause access denied.
Posted
Updated 30-Jun-13 2:24am
v3
Comments
Ron Beyer 30-Jun-13 9:57am    
Did you write the "main" application? Or is this some third-party software you are using?
Hitesh Rohilla 30-Jun-13 18:09pm    
i have wrote main application in visual studio using C#. other applications running in parallel are external applications executed by main application.

1 solution

Hi
I think you can use Mutex Class to find out another instance of running application.

And look at this too:
Single-Instance C# Application - for .NET 2.0


But why wont the application be terminated after shutting down? If some Timers or Threads are used, you must handle it by stopping them before shutting down the app, for example in FormClosed event.

It's not bad to look at these:

Process not terminated at the end of the program

Application.Exit Method
 
Share this answer
 
v2
Comments
Hitesh Rohilla 30-Jun-13 17:54pm    
application safely termination method is written behind close button only and thus it safely shutdown when button is pressed but when form disappear or close unexpectedly then that safely termination method is not called and thus everything remains malfunctioning.

well your suggestions are really good let me give time for full study and try out.

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