Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Elegant way to block
Message
From
01/06/2007 11:24:09
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Elegant way to block
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01229813
Message ID:
01229813
Views:
57
Hi Folks,

I am looking for an elegant way to block waiting for a response from another object. Here is the detail:

I have a serial device and three objects that manage it. The reader object manages only the connection to the serial device but ultimatly sends any commands to the serial device. It also would receive data from the device but does not handle it, only passes it on.

The second object is the command processor and creates an appropriatly formatted command. It then sends the command to the reader object to be forwarded to the serial device.

The third object is a Response Monitor. The response monitor is handed the incoming data from the reader object to sort out and pass on depending on what it is.

Now the issue. When the command processor sends a command to the reader it expects a response in the form typically of "OK>" The response monitor will forward this on to the command processor when it is received, but I need to block or queue any additional commands until a response is either received by the previous command or a timeout period occurs. I was considering using a Mutex, but the thread calling would be the same so it would not block. I could use some form of just plain blocking but would have a hard time incorporating a timeout and recovery.

Anybody have any ideas for an elegant way to do this?
Thanks
Tim
Timothy Bryan
Reply
Map
View

Click here to load this message in the networking platform