Re: A threading problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

[...]
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
method is synchronized with the other.

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

.



Relevant Pages

  • Re: A threading problem
    ... If you want to synchronize the two methods, ... The question you posted is confusing for a couple of reasons: ... it safe to assume that you actually create the OutputBuffer timer using ... is no "receive message thread" per se. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Read file using multithreads
    ... to synchronize the access, thereby the UI would be blocked, and I dont know ... [MS MVP for DirectShow / MediaFoundation] ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Synchronization
    ... We do use Active Directory. ... Although I dont know that you can change what is synchronized. ... The Synchronize is ... the server. ...
    (microsoft.public.windowsxp.general)
  • Re: How to synchronize 4 threads.
    ... > I need to synchronize 4 different threads. ... I dont think waitand ... > notifyall() will work. ... Prev by Date: ...
    (comp.lang.java)
  • Active Sync with Outlook - problems - !!!
    ... I cant synchronize my Outlook 2002 for weeks... ... now, I dont ...
    (microsoft.public.pocketpc.activesync)