N
nick.fletcher
This concerns controlling access to methods in different classes.
The meat of it is as follows:
public class CommsControl
{
private InputBuffer ib = new InputBuffer();
private OutputBuffer ob = new OutputBuffer();
ib.StartComms();
ob.StartComms();
}
protected class InputBuffer
{
private lockObj;
public StartComms()
{
System.Threading.Timer t = new
System.Threading.Timer(this.ReceiveMessages, null, 0, 500);
}
private ReceiveMessages(object stateInfo)
{
lock(lockObj);
{
Do Some Stuff...........
}
}
}
protected class OutputBuffer
{
private lockObj;
public StartComms()
{
System.Threading.Timer t = new
System.Threading.Timer(this.ReceiveMessages, null, 0, 200);
}
private SendMessages(object stateInfo)
{
lock(lockObj);
{
Do Some Stuff...........
}
}
}
Now, I want to be able to block the sending of messages if the receive
message thread is still running. I can do this with a flag but thats
not very nice - Ive also tried using waitOne but with no joy. Anyone
got any suggestions? Many thanks
The meat of it is as follows:
public class CommsControl
{
private InputBuffer ib = new InputBuffer();
private OutputBuffer ob = new OutputBuffer();
ib.StartComms();
ob.StartComms();
}
protected class InputBuffer
{
private lockObj;
public StartComms()
{
System.Threading.Timer t = new
System.Threading.Timer(this.ReceiveMessages, null, 0, 500);
}
private ReceiveMessages(object stateInfo)
{
lock(lockObj);
{
Do Some Stuff...........
}
}
}
protected class OutputBuffer
{
private lockObj;
public StartComms()
{
System.Threading.Timer t = new
System.Threading.Timer(this.ReceiveMessages, null, 0, 200);
}
private SendMessages(object stateInfo)
{
lock(lockObj);
{
Do Some Stuff...........
}
}
}
Now, I want to be able to block the sending of messages if the receive
message thread is still running. I can do this with a flag but thats
not very nice - Ive also tried using waitOne but with no joy. Anyone
got any suggestions? Many thanks