Is it evil to update a pictureBox from a background C# thread?

前端 未结 3 766
失恋的感觉
失恋的感觉 2020-12-12 02:16

First of all, the code below seems to be working. It extracts jpeg images from a continuous byte stream and displays them in a pictureBox as they arrive if the encapsulating

3条回答
  •  一生所求
    2020-12-12 03:08

    Are you sure that even works at all? I don't see why it wouldn't raise a InvalidOperationException: (Cross-thread operation not valid) as the control is being updated from a thread other than the one which is was created on. You should update the UI via a delegate method that is invoked on the UI thread.

提交回复
热议问题