我收到一条InvalidOperationException
with 消息Cross-thread operation not valid..
_waitForm
是在主窗体的构造函数中创建的。屏幕截图中的方法是从另一个线程调用的。我虽然这是BeginInvoke
解决问题的方法。我知道我正在从另一个线程而不是创建的线程访问表单。关于如何解决这个问题的任何想法?
这是堆栈跟踪:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.get_ContainsFocus()
at System.Windows.Forms.Control.SelectNextIfFocused()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Hide()
at YYYYYY.Boundary.ZzzzzForm.<HideWaitForm>b__c() in R:\Projects\XXXX\trunk\src\YYYYYY\Boundary\ZzzzzForm.cs:line 514
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
抱歉截图,我想展示整个图片