Re: A threading problem
- From: nick.fletcher@xxxxxxxxxxxx
- Date: 22 Nov 2006 19:23:35 -0800
Sorry
1) The missing call to send messages is a typo
2) I dont really care which thread the send and receive happens on, so
long as they dont block. Therefore Im just using worker threads
However - your assumptions were correct and hopefully everything is now
sorted.
Cheers
Nick
On Nov 23, 1:40 pm, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx>
wrote:
<nick.fletc...@xxxxxxxxxxxx> wrote in messagenews:1164243206.413576.189130@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[...]method is synchronized with the other.
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 thanksThe code you posted uses two different objects for locking. So, neither
If you want to synchronize the two methods, so that they cannot occur
simultaneously, they need to use a common synchronization object. Whether
this is a mutex, or a lock on a shared object, or even using a waitable
event to synchronize their efforts, the synchronization has to be through a
single object.
The question you posted is confusing for a couple of reasons:
First, in the code you posted you don't seem to be calling
OutputBuffer.SendMessages at all. But you also haven't defined
OutputBuffer.ReceiveMessages, which is what you do appear to call. So, is
it safe to assume that you actually create the OutputBuffer timer using
SendMessages? If not, why not and what is the correct code?
Second, it's not clear to me what "thread" it is you want to depend on. You
haven't created any threads. You've just created a timer that calls a
particular method on a regular basis. That happens on a thread, but there
is no "receive message thread" per se.
But hopefully, the real issue is simply that you aren't using the same
object for the send and receive as far as locking goes. If that didn't
answer your question, you might want to clarify the confusing parts of your
post.
Pete
.
- References:
- A threading problem
- From: nick . fletcher
- Re: A threading problem
- From: Peter Duniho
- A threading problem
- Prev by Date: Re: Convert an Image to 8-bit grayscale
- Next by Date: Re: Convert an Image to 8-bit grayscale
- Previous by thread: Re: A threading problem
- Next by thread: How do I use HTML textbox in C#?
- Index(es):
Relevant Pages
|