Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-31 Thread Fabian Schmied
> >What about Thread.Interrupt? Isn't that for waking up a thread that's > >currently sleeping? > > Thread.Interrupt is documented with "...If this thread is not currently > blocked in a wait, sleep, or join state, it will be interrupted when it > next begins to block.". > > You can use Thread.Inte

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Peter Ritchie
>What about Thread.Interrupt? Isn't that for waking up a thread that's >currently sleeping? Thread.Interrupt is documented with "...If this thread is not currently blocked in a wait, sleep, or join state, it will be interrupted when it next begins to block.". You can use Thread.Interrupt but it i

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Peter Osucha
ay! :-)) Peter -Original Message- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Per Bolmstedt Sent: Friday, March 28, 2008 12:41 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Thread implementation issue On Fri, 28 Mar 2008 10:58:05 -040

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Robert Lee
otection to keep the casual hacker out. HTH, Rob -Original Message- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Per Bolmstedt Sent: Friday, March 28, 2008 12:41 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Thread implementati

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Per Bolmstedt
On Fri, 28 Mar 2008 10:58:05 -0400, Peter Osucha <[EMAIL PROTECTED]> wrote: > In working on implementing the Producer/Consumer queue from comments > earlier this week, [...] Actually, there's no need for sleeping threads in a producer/consumer queue, so I'd say your Blinker is something else, lik

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Stoyan Damov
Still, if you (as somebody else suggested) wait on a ManualResetEvent or event Monitor.Wait(onSomeObject) with timeout you don't need the sleeps and the _stop thing, just: for ( ; ; ) { SePinState(on); if (!stopEvent_.Wait(TimeSpan.FromMilliseconds(_onIntervalMs), false)) { bre

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Fabian Schmied
> The code in the 'Go' method of Blinker is... > >public void Go ( ) >{ >_stop = false; >while ( !_stop ) >{ >SetPinState(on); >Thread.Sleep ( TimeSpan.FromMilliseconds ( _onIntervalMs > ) ); >SetPi

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Fabian Schmied
> One thing you'll run into is the only thing you'll be able to do with this > thread while it's blocked on Thread.Sleep is to terminate it abnormally. > There is, of course, no way to do this in the framework (without using > PInvoke). What about Thread.Interrupt? Isn't that for waking up a threa

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Peter Osucha
ced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Peter Vertes Sent: Friday, March 28, 2008 11:51 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Thread implementation issue On Fri, Mar 28, 2008 at 11:44 AM, Ryan Heath <[EMAIL PROTECTED]> wrote: > > Did you i

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Peter Vertes
On Fri, Mar 28, 2008 at 11:44 AM, Ryan Heath <[EMAIL PROTECTED]> wrote: > > Did you implement a Finalize as well, which calls your Dispose method? > > Without a Finalize, nobody is going to call your Dispose method for you. > +1 to what Ryan said. Without a Finalize it would be up to you to call

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Ryan Heath
> If I didn't want to set the 'IsBackgroud' property of the thread, I > figured I could just implement IDisposable in my class and set > Blinker.Stop=true in Dispose(). However, that didn't seem to work. > Should it have worked? How else might I ensure that the blinkerThread > is ended correctly?

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Fabian Schmied
> If I didn't want to set the 'IsBackgroud' property of the thread, I > figured I could just implement IDisposable in my class and set > Blinker.Stop=true in Dispose(). However, that didn't seem to work. > Should it have worked? How else might I ensure that the blinkerThread > is ended correctly?

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Barry Kelly
Peter Osucha <[EMAIL PROTECTED]> wrote: > As a test example, I have an IO line that I want to 'blink' (turn on and > off for 250ms each). I figured I could easily do this with a separate > thread. > a while loop that continuously blinks the IO line using > Sleep() statements - and one other pro

Re: [ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Peter Ritchie
What does Blinker.Stop do? One thing you'll run into is the only thing you'll be able to do with this thread while it's blocked on Thread.Sleep is to terminate it abnormally. There is, of course, no way to do this in the framework (without using PInvoke). So, a couple of suggestions: don't use Th

[ADVANCED-DOTNET] Thread implementation issue

2008-03-28 Thread Peter Osucha
A bit long but I am trying to clearly explain what I have done and the issue that has arisen... In working on implementing the Producer/Consumer queue from comments earlier this week, I am doing much more (and needed) reading on threads and thread safety. As a test example, I have an IO line that