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
VulpesRank #55 · 29.2K reputationPosted Dec 19, 2012, 6:36 AM EST
If it is, it may be that all you need is :
AccessFormMarshall(InputData);
if the method (as its name suggests) deals with marshalling internally.
VulpesRank #55 · 29.2K reputationPosted Dec 19, 2012, 5:35 AM EST
Glenn PattonRank #6,159 · 275 reputationPosted Dec 19, 2012, 5:55 AM EST
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
VulpesRank #55 · 29.2K reputationPosted Dec 19, 2012, 6:15 AM EST
If it doesn't deal with marshalling, then I'd wrap it in the following which does:
Glenn PattonRank #6,159 · 275 reputationPosted Dec 19, 2012, 6:22 AM EST
Glenn PattonRank #6,159 · 275 reputationPosted Dec 19, 2012, 6:41 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts