zoukankan      html  css  js  c++  java
  • Value Dispose() cannot be called while doing CreateHandle().

    在backgroundWorker run之前show出了一个窗体_frm.

    _frmpw = new FrmPleaseWait();
    _frmpw.SetMsg("正在请求");
    _frmpw.Show();

    bw.RunWorkerAsync();

    在backgroundWorker RunWorkerCompleted事件中准备去关闭这个窗口

    private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
    if (_frmpw != null && !_frmpw.IsDisposed)
    _frmpw.Close();

    如果DoWork事件中的任务完成的非常快,_frmpw还未创建完成时就去访问_frmpw.IsDisposed属性就会出现Value Dispose() cannot be called while doing CreateHandle().

    解决方法,只能在DoWork事件中加SLEEP了。

    private void bw_DoWork(object sender, DoWorkEventArgs e)
    {
    System.Threading.Thread.Sleep(300);//防止Value Dispose() cannot be called while doing CreateHandle()

    -----------

  • 相关阅读:
    closure
    运算符优先级
    css妙用
    BFC (块级格式化上下文)
    display:table-cell 详解
    line-height深入理解
    margin collapse
    探究 CSS 解析原理
    python入门
    spring与线程安全
  • 原文地址:https://www.cnblogs.com/runliuv/p/5163120.html
Copyright © 2011-2022 走看看