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});
}
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});
}