Re: Waiting on a Thread - Revisited

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 05/27/04


Date: Thu, 27 May 2004 16:57:57 +0100

Charles Law <blank@nowhere.com> wrote:
> Hmm. I know you're right ... but ...
>
> I deliberately kept the whole 'read message / update UI' thing inside the
> SyncLock construct because it served as a way of pacing outgoing messages.
>
> Messages have to be sent out synchronously, and the polling thread is
> capable of adding messages to the queue much faster than they can be sent.
> Therefore, locking the queue whilst the message was being sent seemed a
> convenient way of preventing a backlog of messages from building up in the
> queue. However, when the user clicks something, their request takes
> precedence over the background processing, so it is legitimate to insert the
> message at the head of the queue and not have to wait.
>
> Can you think of another way round this?

When you send the message, you can always make the worker thread then
sleep for a short time, so that it's then ready to send or receive
again. If messages are queued faster than they're going to be sent,
there's bound to be a backlog *somewhere* - and in the queue is
probably the best place for them.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: Waiting on a Thread - Revisited
    ... I don't want to add any artifical pacing because the ... The number of messages being sent by the polling thread is not important, ... locking the queue whilst the message was being sent ... If messages are queued faster than they're going to be sent, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Waiting on a Thread - Revisited
    ... I don't want to add any artifical pacing because the ... The number of messages being sent by the polling thread is not important, ... locking the queue whilst the message was being sent ... If messages are queued faster than they're going to be sent, ...
    (microsoft.public.dotnet.general)
  • Re: Waiting on a Thread - Revisited
    ... > Messages have to be sent out synchronously, and the polling thread is ... > capable of adding messages to the queue much faster than they can be sent. ... > convenient way of preventing a backlog of messages from building up in the ... If messages are queued faster than they're going to be sent, ...
    (microsoft.public.dotnet.general)
  • [fw-wiz] [Administrivia] Backlog, Vacations...
    ... Iv'e finally cleared the backlog of old stuff out of the queue, ... autoresponders set to not reply to messages with Precedence: ... Paul D. Robertson "My statements in this message are personal opinions ...
    (Firewall-Wizards)
  • Re: epoll behaviour after running out of descriptors
    ... Additions to the backlog, triggers new events, ... Shouldn't ET only fire again *after* you drained the queue? ... accept returns EMFILE, you did not drain the queue. ...
    (Linux-Kernel)

Quantcast