Hi All,
I have written a delegate to mange data from the serial port. I would like to use it to display the data on the form I have been told that I need to use an
Invoke to do this. I am having some issues using the invoke command. I have an instance of the form I wish the data to be shown on
internal static Form1 myForm1;
later in the code I am using the commands:
InputData = myComPort.ReadExisting();
myForm1.Invoke(AccessFormMarshall(InputData));
I belive I have set up the Access and Marshalling correctly. I think it is the use of the invoke command correctly.
Glenn
VulpesPosted Dec 19, 2012, 11:36 AM
If it is, it may be that all you need is :
AccessFormMarshall(InputData);
if the method (as its name suggests) deals with marshalling internally.
Glenn PattonPosted Dec 19, 2012, 11:41 AM
Glenn PattonPosted Dec 19, 2012, 11:22 AM
VulpesPosted Dec 19, 2012, 11:15 AM
If it doesn't deal with marshalling, then I'd wrap it in the following which does:
Glenn PattonPosted Dec 19, 2012, 10:55 AM
Thanks for that... but I now get:
Error 1 The best overloaded method match for 'System.Windows.Forms.Control.Invoke(System.Delegate, params object[])' has some invalid arguments C:\Users\glennp\Dropbox\PSION Emmulation\PSION Emmulation\PSION_EmmualtionA\TestBoardComms\WindowsFormsApplication152\WindowsFormsApplication152\Form1.cs 192 25 WindowsFormsApplication152
and.....
Error 2 Argument '1': cannot convert from 'method group' to 'System.Delegate' C:\Users\glennp\Dropbox\PSION Emmulation\PSION Emmulation\PSION_EmmualtionA\TestBoardComms\WindowsFormsApplication152\WindowsFormsApplication152\Form1.cs 192 40 WindowsFormsApplication152
I have included the full error message as a guide it seems to not attaching the marshall delegate properly. Sorry to be a bit vague but I appear to have got everything behind it working, but not the invoke to make it work! The reference given I have seen and tried to use was: Form1.AccessFormMarshall(recievedData);
from that I tried to use: myForm1.Invoke(AccessFormMarshall(InputData));
Does this help at all (?)
Glenn
VulpesPosted Dec 19, 2012, 10:35 AM