|
-
May 16th, 2011, 08:41 AM
#1
Process Exit Event Handler
I am currently working with the .NET Process Class and there is an event handler for when a process you execute from C# closes will fire off of an event.
Now my process is that my program will execute a java program that will generate a text file. The C# program will detect the closure and open the generated text file. The problem is when I execute this code again instead of one text file opening, two open, and then three, four, etc, etc every time I execute this code.
My first suspicion was that it was taking into account notepad closing but if I leave notepad open the same issue occurs so this seems to rule out that conclusion.
Any ideas?
Code:
jProcess.StartInfo = processStartInfo;
jProcess.EnableRaisingEvents = true;
jProcess.Exited += new EventHandler(jProcess_Exited);
jProcess.Start();
Here is the method I fire off.
Code:
private void jProcess_Exited(object sender, EventArgs e)
{
jProcess.EnableRaisingEvents = false;
Process.Start(file);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|