A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.
I am doing some serial communication to a divice using .NET 2.0. The device has a set of simple commands, each command and responce is a fix size. Each command will generate a responce and a new command can not be sent until the responce from the previous command has been recived. I have set the DataReceived event handler ta a
method that will read the responce data. That part works OK. There is a flag in the event handler that I set when I read the response. I poll for that flag to see when I can sent the next command. My question is is there any way I can know when it is OK to send the next command without polling?
MSDN tells me that DataReceived events occurs on a worker thread. System.Threading.Monitor with its Wait and Pulse methods might do what you want.
It sounds like your app is event driven, if so you can create a CanSend event and have your DataReceived handler raise this when it is safe to send another command.
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz