Com port and priorities

  • Thread starter Thread starter Gianmaria
  • Start date Start date
G

Gianmaria

Hi,
i'm workin to a project where i use a serial port to send and receive data.
My objects send messages to the port by some methods.. no problem till now.
I receive and send data. The problem is that i have to send a string signal
every 25 seconds to tell the remote device i'm still connected.. now the
problem is that i cant control if that signal is sent while my users are
sending some other signals using objects methods. How can i stop all others
to send when my object is sending the keep alive signal?



regards
Gianmaria
 
Hi Gianmaria,

Take a look at using the System.Threading.Monitor class to gain
exclusive access to the serial port.

If the timing of your 25s control signal is extremely sensitive you'll
need to write the other object methods carefully. You need to prevent
another thread from grabbing the Monitor for long periods of time when
it sends user data.

See Jon's document for a good introduction to Monitor:
http://www.yoda.arachsys.com/csharp/multithreading.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Com ports 2
Creating a COM Port 1
Server not receiving write() here and there 1
ThreadPool and WaitHandle 1
USB Com ports 6
convert Hex to UTF8 and Vice Versa 9
Best design : wcf ? 1
Serial port proxy 1

Back
Top