Hi folks,
I wish to pass some data to the delegate method, of a Process
object, when it fires the Exited
event --- i'm not sure how.
I've got some code (in a windows service) that is going to take a while .. so i'm forking off a new process to do it .. like ...
string recipientEmail = "[email protected]";
var commandProcess = new Process
{
StartInfo =
{
FileName = commandLine,
Arguments = commandArgs
}
};
commandProcess.Start();
Now, when this finishes, I wish to do some other stuff. For example, send an email.
Now, that's not too hard when we can :-
commandProcess.EnableRaisingEvents = true;
// Method to handle when the process has exited.
commandProcess.Exited += CommandProcess_Exited;
Now, i'm not sure how i pass the variable recipientEmail
to the method CommandProcess_Exited
when the Exited
event is fired.
eg method which the CommandProcess_Exited
method will call :-
private static void SendEmailToRecipient(string recipientEmail)
{
....
}
Is this possible?