Link to home
Start Free TrialLog in
Avatar of jdcoburn
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, SerialDataReceivedEventArgs e)
{
int numBytesRead = port.Read(receiveBuffer, 0, 200);
                    UpdateDisplay ud = new UpdateDisplay(UpdateDisplayMethod);

                    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.Control' via nested type 'Control_Editor.CT_UI_Control.MatrixDisplay'

 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
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jdcoburn
jdcoburn

ASKER

yes - you were correct. it was a typo that I didn't catch until after I had posted this.
thanks,