调试显示,执行到这一句时:
DisplayLog dFunc = new DisplayLog(SetTxtLog);
this.Invoke(dFunc, new object[] { s });
报错:
“在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke”
DisplayLog dFunc = new DisplayLog(SetTxtLog);
this.Invoke(dFunc, new object[] { s });
报错:
“在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke”
我把代码改成:
if (txtLog.IsHandleCreated)
{
DisplayLog dFunc = new DisplayLog(SetTxtLog);
if ((!this.IsDisposed) && (this!=null) && (this.IsHandleCreated) && (!txtLog.IsDisposed))
this.Invoke(dFunc, new object[] { s });
}错误提示变成了:
无法访问已释放的对象。
对象名:“FrmMain”。
return;