Re: thread unstarted

From: BMermuys (someone_at_someone.com)
Date: 03/20/04


Date: Sat, 20 Mar 2004 04:03:29 +0100

Hi,
[inline]

"Kovan Akrei" <kovana@ifi.uio.no> wrote in message
news:e8FGFieDEHA.3280@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> When I check whether one my thread are running I use a bitmask like this:
>
> (myThread.ThreadState & (ThreadState.Stopped | ThreadState.Unstarted)) ==
0
> (got it from MSDN)
>
> How would I check whether a thread has been started or not without using
the
> property IsAlive? I'm trying to use a bit mask like this;
>
> if ((myThread.ThreadState | ThreadState.Unstarted) = = 8)
> myThread.Start();

What about :

if ( (myThread.ThreadState & ThreadState.Unstarted) ==
ThreadState.Unstarted)
    myThread.Start();

For masking bits, use the &-operator.

>
> but I get an error message :
> Operator '= =' cannot be applied to operands of type
> 'System.Threading.ThreadState' and 'int'.
> I'm I doing something wrong? I can fix this by retyping av the bitmask to
> (int),

Don't know what you mean with 'av', but you can safely cast int to
threadstate or threadstate to int.

HTH,
greetings

> but I was wondering if there is another way to bitmask and get the
> right result?
>
> Regards from
> Kovan
>
>



Relevant Pages

  • Re: SET, CLR, ISSET in types.h for _KERNEL builds
    ... AL>> reason to needless deviate from NetBSD here. ... AL>> it really matter enough to justify having it be different than NetBSD? ... AL>> Here's my proposed diff, inline, for your consideration: ... AL>Who not create abstract framework for work with bitmask more then 64bits ...
    (freebsd-arch)
  • thread unstarted
    ... When I check whether one my thread are running I use a bitmask like this: ... (got it from MSDN) ... 'System.Threading.ThreadState' and 'int'. ... Regards from ...
    (microsoft.public.dotnet.languages.csharp)