Secondary Stream Management Update: Critically Critical?

The C # Im application that is being developed consists mainly of operations with images coming from the camera and printing them on a graphic box. It has a library written in C ++ that extracts images from a webcam (imgcam) and creates copies of them (imgcam_copy), then they are delivered to a managed code that requests them. In turn, the managed part of the application consists of a secondary thread that executes the while loop, which receives images from the unmanaged library and prints them in the image box.

Everything works fine, and the thinnest part of everything, that is, managing dynamic resources from unmanaged managed code, seems obvious to me, and Im knows what I'm doing (at least I hope), but the problem is that writing the code is necessary for the correct operation of threads. Indeed, there are many things that are not clear to me, even after several hours of browsing the Internet.

I have to print the image using the UI thread, so I have to rely on Invoke.

    delegate void setImageCallback(Image img);
    private void showFrame(Image img)
    {
        if (pboxCam.InvokeRequired)
        {
            this.Invoke(new setImageCallback(showFrame), img);
        }
        else
        {
            pboxCam.Image = img;
        }
    }

I have a lot of questions:

1) Is an expensive operation called up? Ive made a lot of efforts to reduce the time it takes to perform basic operations on images, it would be disappointing to spend some of the benefits simply by demonstrating the result.

2) Do you think it is better to use Invoke synchronously or BeginInvoke + a copy of the image asynchronously?

3) , ?

    private delegate void setImageCallback();
    private void showFrame()
    {
        if (pboxCam.InvokeRequired)
        {
            this.Invoke(new setImageCallback(showFrame));
        }
        else
        {
            pboxCam.Image = cm.bitmap;
        }
    }

4), , , , , . , , , , ?

+4
1

Invoke , () . , , , . - , , , Invoke, .

, . , , Invoke . , , .

img .

BeginInvoke , . BeginInvoke , , , . BeginInvoke, , , -, , , , , . , .

, , . , , Invoke, , .

Invoke , , , . BeginInvoke, , , . , .

, : " ". , . , BeginInvoke . , , Invoke. .

. , , "!". , , , . Windows , .

+5

Source: https://habr.com/ru/post/1531674/


All Articles