C# 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke

http://www.cnblogs.com/fish124423/archive/2012/10/16/2726543.html

 

在Invoke(....)之前加上1 this.components==null 2 this.IsDisposed 3 IsHandleCreated 来return 不执行invoke就可以,当然只是我针对自己遇到的解决的,可能并不适合其他的,但是总不会脱离其中

if (IsDisposed ||!this.Parent.IsHandleCreated) return;

if (this.IsDisposed) { return; }
if (this.Parent != null && !this.Parent.IsHandleCreated) { return; }
 if (this.IsHandleCreated)
{

       this.BeginInvoke(new EventHandler(delegate
       {
                            if (bw.IsBusy) { bw.ReportProgress(i); }

       }));
}

 

 
posted @ 2018-12-22 17:06  LuoCore  阅读(1233)  评论(0)    收藏  举报