By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

Exit event not getting triggered for a process

P: 5
Hi All,

I'm trying to get the exit time of a process. But the event is not getting triggered when i'm closing the process. Below is the code which i have tried. Any help would do.

ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.FileName = "notepad.exe";
startInfo.Arguments = @"E:\shared\perdata.txt";
startInfo.WorkingDirectory = @"C:\Temp";
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.ErrorDialog = true;

try
{
oProcess.EnableRaisingEvents = true;
oProcess.Exited += new EventHandler(ProcessExited);
oProcess = Process.Start(startInfo);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

The event to be triggered when the file is closed:
public void ProcessExited(object sender,System.EventArgs e)
{
MessageBox.Show(oProcess.ExitTime.ToString());
}



Thanks in advance,
deviparimala
Apr 21 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.