我有这个运行的代码.exe
string openEXE = @"C:\Users\marek\Documents\Visual Studio 2012\Projects\tours\tours\bin\Debug\netpokl.exe";
Process b = Process.Start(openEXE);
b.EnableRaisingEvents = true;
b.Exited += (netpokl_Closed);
当它关闭时,它调用方法 netpokl_Closed。问题是当我insert into netpokl_Closed command
- this.Close()
出现此异常:Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on
我该如何解决它?感谢您的时间和答复。
您收到异常是因为您试图从创建该表单的线程以外的线程关闭该表单。这是不允许的。
像这样做
this.Invoke((MethodInvoker) delegate
{
// close the form on the forms thread
this.Close();
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)