How can a background thread hang the UI thread?

后端 未结 4 1244
野性不改
野性不改 2021-01-13 09:00

I am using a background thread to initialize an instrument over USB. The UI hangs when I try to open the device. I would expect the background thread to pause when calling O

4条回答
  •  -上瘾入骨i
    2021-01-13 09:32

    I would suggest you wrap the call to meter.open() in a separate method, and call that method from within the updateMeter() method using Invoke() or BeginInvoke() construct on the form or parent control. Doing this will marshal the action back on to the UI thread and should execute gracefully. I hope this helps.

提交回复
热议问题