rognorak
January 22nd, 2007, 04:06 PM
I am writing a class that inherets "public System::IO::Ports::SerialPort"
I also have 2 timers instantiated inside the class of type "System::Timers::Timer^"
I define a custom event / delegate pair, and every time i try to raise my event from within a timer event handler or the serialport class DataReceived event handler, the application generates an exception of:
System.Invalidoperation exception
this seems to be because the timer elapsed event and the serialport Datareceived Event are operating on seperate threads from the main application.
I was able to aleviate the problem with the timer object by setting the "SynchronizingObject" property of the timers to a handle to the form on which my top level class is instantiated.
However, the SerialPort class does not have this property.
Any Idea how to aleviate this problem for the serial port events? Research indicates using the Forms->invoke() method of the form on which my top level object is instantiated - but I do not know how to do this
Thank You
I also have 2 timers instantiated inside the class of type "System::Timers::Timer^"
I define a custom event / delegate pair, and every time i try to raise my event from within a timer event handler or the serialport class DataReceived event handler, the application generates an exception of:
System.Invalidoperation exception
this seems to be because the timer elapsed event and the serialport Datareceived Event are operating on seperate threads from the main application.
I was able to aleviate the problem with the timer object by setting the "SynchronizingObject" property of the timers to a handle to the form on which my top level class is instantiated.
However, the SerialPort class does not have this property.
Any Idea how to aleviate this problem for the serial port events? Research indicates using the Forms->invoke() method of the form on which my top level object is instantiated - but I do not know how to do this
Thank You