Re: Waiting on a Thread - Revisited
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 05/27/04
- Next message: Charles Law: "Re: Waiting on a Thread - Revisited"
- Previous message: Herfried K. Wagner [MVP]: "Re: vb.net & word"
- In reply to: Charles Law: "Re: Waiting on a Thread - Revisited"
- Next in thread: Charles Law: "Re: Waiting on a Thread - Revisited"
- Reply: Charles Law: "Re: Waiting on a Thread - Revisited"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Charles Law: "Re: Waiting on a Thread - Revisited"
- Previous message: Herfried K. Wagner [MVP]: "Re: vb.net & word"
- In reply to: Charles Law: "Re: Waiting on a Thread - Revisited"
- Next in thread: Charles Law: "Re: Waiting on a Thread - Revisited"
- Reply: Charles Law: "Re: Waiting on a Thread - Revisited"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|