A threading problem
- From: nick.fletcher@xxxxxxxxxxxx
- Date: 22 Nov 2006 16:53:26 -0800
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
.
- Follow-Ups:
- Re: A threading problem
- From: Peter Duniho
- Re: A threading problem
- Prev by Date: Re: User control constructor called twice
- Next by Date: How do I use HTML textbox in C#?
- Previous by thread: An instance of a form in another
- Next by thread: Re: A threading problem
- Index(es):