Problem with Invoke(Delegate, object[]) : No overload takes 2 arg

G

Guest

Hi,

I am doing an application using 2 threads, one for the UI, and one for
network access.

The network thread reads an image from a socket, and then displays it in a
PictureBox. In order to do it properly, the network thread calls the
"callDelegate" method which calls the Invoke (Delegate, Object[]) method on
the PictureBox object.

The problem is that it refuses to Build.... i get the error :
"No overload for method 'Invoke' takes '2' arguments"

I imagine it is because the method "Control.Invoke(Delegate, Object[])" is
virtual... so i guess I have to implement it... how to do it ? what to write
?

I guess it is obvious for most of you... but i'm new to C#..

my code:

private delegate void PictureBoxDelegate(Bitmap image);

public void displayFrame(Bitmap frame)
{
this.pictureBox1.Image = frame;
}

public void callDelegate(Bitmap frame)
{
this.pictureBox1.Invoke(new PictureBoxDelegate(displayFrame), new
object[] {frame});
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top