Re: Thread.Sleep...
When I said spinwait i meant a Thread.Sleep(Fr equency); not per iteration
as in SpinWait(N);
Maybe a bad choice of terminology.
"Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
news:MPG.1a0c29 0011216dcc9899b e@msnews.micros oft.com...[color=blue]
> news.microsoft. com <discussion@dis cussion.microso ft.com> wrote:[color=green]
> > I used the AutoResetEvent. Set to signal the worker thread and
> > AutoResetEvent. WaitOne() to put it to sleep.
> >
> > I dont see the need for Monitor.Wait and Monitor.Pulse as the shared[/color][/color]
item is[color=blue][color=green]
> > already using the synchronised wrapper.[/color]
>
> You're certainly only like to need *either* AutoResetEvent *or*
> Monitor.Wait/Pulse, but I don't see why using a synchronised wrapper
> would knock Monitor.Wait/Pulse out of the equation.
>[color=green]
> > I still have a spin wait so its working on the items at a good pace and[/color][/color]
not[color=blue][color=green]
> > burning the CPU from other more important threads.[/color]
>
> I don't think a spin wait is a particularly good way of doing that
> though - why not just sleep briefly? IIRC, the purpose of spin waits is
> to wait *without* yielding to another thread, if you have a good reason
> to believe that the reason you're unwilling to do more work is about to
> be removed, as it were.
>[color=green]
> > Is it possible to prioritise threads?[/color]
>
> Sort of - have a look at the Thread.Priority property. Note that it
> doesn't have to be honoured.
>
> --
> Jon Skeet - <skeet@pobox.co m>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too[/color]
When I said spinwait i meant a Thread.Sleep(Fr equency); not per iteration
as in SpinWait(N);
Maybe a bad choice of terminology.
"Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
news:MPG.1a0c29 0011216dcc9899b e@msnews.micros oft.com...[color=blue]
> news.microsoft. com <discussion@dis cussion.microso ft.com> wrote:[color=green]
> > I used the AutoResetEvent. Set to signal the worker thread and
> > AutoResetEvent. WaitOne() to put it to sleep.
> >
> > I dont see the need for Monitor.Wait and Monitor.Pulse as the shared[/color][/color]
item is[color=blue][color=green]
> > already using the synchronised wrapper.[/color]
>
> You're certainly only like to need *either* AutoResetEvent *or*
> Monitor.Wait/Pulse, but I don't see why using a synchronised wrapper
> would knock Monitor.Wait/Pulse out of the equation.
>[color=green]
> > I still have a spin wait so its working on the items at a good pace and[/color][/color]
not[color=blue][color=green]
> > burning the CPU from other more important threads.[/color]
>
> I don't think a spin wait is a particularly good way of doing that
> though - why not just sleep briefly? IIRC, the purpose of spin waits is
> to wait *without* yielding to another thread, if you have a good reason
> to believe that the reason you're unwilling to do more work is about to
> be removed, as it were.
>[color=green]
> > Is it possible to prioritise threads?[/color]
>
> Sort of - have a look at the Thread.Priority property. Note that it
> doesn't have to be honoured.
>
> --
> Jon Skeet - <skeet@pobox.co m>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too[/color]
Comment