Invoke() is blocking

前端 未结 4 2305
慢半拍i
慢半拍i 2021-02-12 12:49

From time to time my applications GUI stops redrawing. There a lot of threads that are firing all kinds of events (like timers or network data ready etc.). Also there are a lot

4条回答
  •  感动是毒
    2021-02-12 13:24

    Deadlock perhaps? Do you make sure that the events are never fired while holding a lock?

    Are you able to see this with a debugger attached? If so, make it freeze and then hit the "pause" button - and see what the UI thread is doing.

    Note that if you are able to get away with BeginInvoke instead of Invoke, life is a bit easier as it won't block.

    Also note that you don't need the "new EventHandler" bit - just

    Invoke((EventHandler) MyEventHandler, sender, e);
    

    should be fine.

提交回复
热议问题