Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have small task, I need to kill process and start the same process after some timespan
I have code like below
C#
var procName = Process.GetCurrentProcess().ProcessName;
                   Thread.Sleep(30000);
                   Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                   Process.GetProcessById(Process.GetCurrentProcess().Id).WaitForExit();
                   Thread.Sleep(30000);
                   Process.Start(procName);


Process is not able to start after I kill it.

please help me.

Thanks,
-RG
Posted
Comments
ErBhati 4-Mar-14 2:35am    
I think u use procees.resume();
[no name] 4-Mar-14 2:37am    
So you want to start it after what timespan - 3 days? A Lazarus process. You are serious I assume.
Read this and think about what you are asking http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill(v=vs.110).aspx.
Ramug10 4-Mar-14 2:40am    
after 2 min
[no name] 4-Mar-14 2:42am    
It's dead and gone.
Ramug10 4-Mar-14 2:45am    
how to resume it again.

1 solution

We have a similar task: at startup, the program looks for updates, and if the executable proper needs to be updated, that file is locked of course when it is running...
So we use an extra application (our Updater) which is started with a few arguments (including the path of the current executable), the original program exits (Application.Exit), the Updater performs the update after a short waiting period, and after that starts the original application again (it received the path as an argument, thus knows which executable to call).
That's the point here: you need a "helper" application like our Updater.
 
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