Hi all,
First of all, sorry for adding the (Very Urgent) to the title.
We have to demo this program in 4 hours and everything is working but the updating of the display.
I have a bitmap displayed in a Graphics Rectangle.
I manually set the pixels of the bitmap based on info coming in from the serial port.
When I have received 98 values, I want to redraw the scene, I get a "System.ArgumentException: Parameter is not valid" exception:
gForm.DrawImage(bmp, 10, 10, bmp.Width, bmp.Height);
|
So I'm thinking that the problem is cross thread calling so I tried:
this.Invoke(new EventHandler(delegate { gForm.DrawImage(bmp, 10, 10, bmp.Width, bmp.Height); }));
|
I also tried the proper way
this.Invoke(new DoUpdateForm(UpdateForm), bmp);
[...]
private delegate void DoUpdateForm(Bitmap bmp); private void UpdateForm(Bitmap bmp) { gForm.DrawImage(bmp, 10, 10, bmp.Width, bmp.Height);
} |
But the error keeps appearing.
I run the exact same method when I first paint the Form and it works fine.
I am working with VS2010 for the first time so I thought it may have been a change from .net 3.5 to .net 4 so I switched back to .net 3 but it still doesn't work.
Please help!!
Thanks a mil in advance
Paul
ps->The entire code is attached