M
Martijn
Hi,
I am trying to perform asynchronous serial (RS232 port) I/O in C# in a
"proper" manner. I noticed there is an event that will tell me when there
is something on the port, but I can't find a similar construct for writing
to the port.
Although the documenation states that SerialPort.Write() and
SerialPort.WriteLine() write to the buffer, they do not return until all
bytes have been actually transmitted (I tested this by sending 1K @
1200bps). I was hoping for some way to send something to the driver, and be
notified when it was transmitted on the port. Something like what would
happen by specifying FILE_FLAG_OVERLAPPED to the native Win32 CreateFile()
call.
My options:
1) Create my own thread(s) to do the asynchronous reading and writing (seems
a bit expensive)
2) Use P/Invoke on CreateFile and whatever I need to write to it (not really
something I prefer)
3) I have missed something, and there is a "better way"
Any pointers would be greatly appreciated!
Thanks for the help,
I am trying to perform asynchronous serial (RS232 port) I/O in C# in a
"proper" manner. I noticed there is an event that will tell me when there
is something on the port, but I can't find a similar construct for writing
to the port.
Although the documenation states that SerialPort.Write() and
SerialPort.WriteLine() write to the buffer, they do not return until all
bytes have been actually transmitted (I tested this by sending 1K @
1200bps). I was hoping for some way to send something to the driver, and be
notified when it was transmitted on the port. Something like what would
happen by specifying FILE_FLAG_OVERLAPPED to the native Win32 CreateFile()
call.
My options:
1) Create my own thread(s) to do the asynchronous reading and writing (seems
a bit expensive)
2) Use P/Invoke on CreateFile and whatever I need to write to it (not really
something I prefer)
3) I have missed something, and there is a "better way"
Any pointers would be greatly appreciated!
Thanks for the help,