jdcoburn
asked on
serial port Invoke call
hi -
I'm using VS2010 and .net4.0 with a windows form applications.
I have successfully used the following code to handle the return data from a serial device to pass the received data to the original thread:
void port_DataReceived(object sender, SerialDataReceivedEventArg s e)
{
int numBytesRead = port.Read(receiveBuffer, 0, 200);
UpdateDisplay ud = new UpdateDisplay(UpdateDispla yMethod);
if (numBytesRead != 0)
{
Invoke(ud, new object[] { receiveBuffer, numBytesRead });
}
}
I have a slightly different flavor of an application where I create a class which the above code is embedded in. when I try to paste in the invoke code, VS2010 flags it with this error:
Error 29 Cannot access a non-static member of outer type 'System.Windows.Forms.Cont rol' via nested type 'Control_Editor.CT_UI_Cont rol.Matrix Display'
the windows form code creates the class with this code:
MatrixModule = new MatrixDisplay(portNameitem );
I don't understand why i'm getting the error, and more importantly, I don't know what to do about it.
thanks,
I'm using VS2010 and .net4.0 with a windows form applications.
I have successfully used the following code to handle the return data from a serial device to pass the received data to the original thread:
void port_DataReceived(object sender, SerialDataReceivedEventArg
{
int numBytesRead = port.Read(receiveBuffer, 0, 200);
UpdateDisplay ud = new UpdateDisplay(UpdateDispla
if (numBytesRead != 0)
{
Invoke(ud, new object[] { receiveBuffer, numBytesRead });
}
}
I have a slightly different flavor of an application where I create a class which the above code is embedded in. when I try to paste in the invoke code, VS2010 flags it with this error:
Error 29 Cannot access a non-static member of outer type 'System.Windows.Forms.Cont
the windows form code creates the class with this code:
MatrixModule = new MatrixDisplay(portNameitem
I don't understand why i'm getting the error, and more importantly, I don't know what to do about it.
thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks,