> The code in the 'Go' method of Blinker is...
>
>        public void Go (  )
>        {
>            _stop = false;
>            while ( !_stop )
>            {
>                SetPinState(on);
>                Thread.Sleep ( TimeSpan.FromMilliseconds ( _onIntervalMs
> ) );
>                SetPinState(off);
>                Thread.Sleep ( TimeSpan.FromMilliseconds (
> _offIntervalMs ) );
>            }
>        }
>
>        public void Stop ()
>        {
>            _stop = true;
>
>        }

Don't forget that for this to work reliably, _stop must be declared
"volatile". Either that or you must lock a synchronization object
while accessing the _stop variable.
(You cannot reliably access non-volatile state that is shared across
different threads without locking.)

Fabian

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to