Process cExe = new Process();
cExe .StartInfo.FileName = "cexe.exe";
cExe .EnableRaisingEvents = true;
cExe .Exited += this.cExited;
And t开发者_StackOverflow社区his is the exited method
private void cExited(object o, EventArgs e)
{
MessageBox.Show(/* SHOW FILE NAME HERE */);
}
How would i get the information about the process from the exited method? which of the variables (o, e) give me this data and what type are they meant to be?
While working with .Net Base Class Library
, you will find that each event passes two parameters.
First is always of type System.Object
and other is of type (or descendant of) System.EventArgs
.
The first argument that is object sender
can be safely cast into type of class that raised that event. In your case that is of type System.Diagnostics.Process
.
Example:
private void cExited(object o, EventArgs e)
{
Process p = (Process)o;
// Use p here
}
精彩评论