0
我使用這個小工具功能:調用句柄錯誤檢查
public static void Invoke(Control control, Action method)
{
if (control.InvokeRequired)
{
if (control.IsDisposed || !control.IsHandleCreated || !control.Created)
return;
control.Invoke(method);
}
else
method();
}
儘管所有這些健全的檢查,當我關閉我的應用程序,一個流浪調用總是產生這個錯誤:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
這,儘管顯然有一個檢查,看看是否創建句柄...我還能做什麼?
這確實有幫助。當我用BackgroundWorker替換Invoke的所有用法時(它的進度報告事件必須被濫用以達到所需的行爲),它會毫無怨言地運行。 – Reinderien 2011-05-24 06:16:21