zoukankan      html  css  js  c++  java
  • RunWorkerCompleted runs in worker thread

    some problem with .net 2.0: In the application, a form subscribes a RunWorkerCompleted event of a BackgroundWorker. Suppose RunWorkerCompleted() is running in UI thread so some code inside it will do form rendering stuff. The application runs smooth in VS2005 environment, but it is running in worker thread when I run it in production environment (I tested it with InvokeRequired). The production environment has .Net 2.0 and .Net1.1 installed. In another production environment machine, .Net 2.0 and .Net1.1 are installed and this time the method is running in UI thread.

    more investigation:
    in production environment, the first call to RunWorkerCompleted(),
    InvokeRequired returns false. But the second time to call
    RunWorkerCompleted() with the same BackgroundWorker, the InvokeRequired
    returns true.

    so, what we should do is :

    IF(This.InvokeRequired)

       this.Invoke(new Delegate(CallMethod),new object[]{arg1,arg2,xxx});

    ELSE

       CallMethod(arg1,arg2,xxx);

  • 相关阅读:
    numpy
    shell进阶2
    python笔记3
    shell进阶1
    记录:Paxos原理、历程及实战
    收藏
    linux fs io
    linux mount 操作
    docker好文收藏
    rbd snap(1)
  • 原文地址:https://www.cnblogs.com/anorthwolf/p/1867372.html
Copyright © 2011-2022 走看看