Closed hellottyp closed 1 year ago
good,thanks!it works very well.
it works,but it isn't thread-safe.
Could you show me the code that produce the problem?
like this:
camera.BitmapCaptured += (bmp) =>
{
this.textBox1.Text = "hello";
this.BackgroundImage = bmp;
};
You're better off implementing it with events
Are you saying that the line below cause InvalidOperationException? (Cross-thread operation not valid.)
this.textBox1.Text = "hello";
If so, it is your responsibility to call cross-thread control in a thread-safe way.
textBox1.Invoke((Action)(() =>
{
this.textBox1.Text = "hello";
}));
I did it.And it can work.But I have many controls to process.So I will do more work.It's not just convenient.
I use delegates to handle those controls, so I do a lot of things. Using Invoke is much easier.thanks!
Thank you for your response.
Hello. You have to modify UsbCamera.cs a little. Try these changes below and let me know it works fine or not.
Step1. Add this block around line 80.
Step2. Replace this block from
to
Step3. subscribe BitmapCaptured.