C# 进程退出事件帮助
Process cExe = new Process();
cExe .StartInfo.FileName = "cexe.exe";
cExe .EnableRaisingEvents = true;
cExe .Exited += this.cExited;
这是退出的方法
private void cExited(object o, EventArgs e)
{
MessageBox.Show(/* SHOW FILE NAME HERE */);
}
我如何从退出的方法中获取有关进程的信息?哪些变量 (o, e) 为我提供了这些数据以及它们的类型是什么?
Process cExe = new Process();
cExe .StartInfo.FileName = "cexe.exe";
cExe .EnableRaisingEvents = true;
cExe .Exited += this.cExited;
And this 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
.Net 基类库
时,您会发现每个事件都会传递两个参数。第一个始终是
System.Object
类型,另一个是System.EventArgs
类型(或其后代)。第一个参数是对象发送者,可以安全地转换为引发该事件的类的类型。在您的情况下,其类型为 System.Diagnostics.Process 。
例子:
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 typeSystem.Diagnostics.Process
.Example: