ThreadState

  • Thread starter Thread starter Michael Moreno
  • Start date Start date
M

Michael Moreno

Hello,

I am getting a ThreadState value of 12 which I do not know what state
represents

The code is simple and looks like this

private Thread m_Thread;
....
m_Thread = new Thread(new ThreadStart(ThreadLoop));
m_Thread.ApartmentState = ApartmentState.STA;
m_Thread.IsBackground = true;
m_Thread.Priority = ThreadPriority.Normal;
....
MessageBox.Show(m_Thread.ThreadState);

I have tried using a switch statement to find out what the 12 value is
such as:

switch (m_Thread.ThreadState)
{
case System.Threading.ThreadState.Unstarted:
case System.Threading.ThreadState.Stopped:
case System.Threading.ThreadState.Aborted:
case System.Threading.ThreadState.Background:
case System.Threading.ThreadState.Suspended:
case System.Threading.ThreadState.AbortRequested:
case System.Threading.ThreadState.Running:
case System.Threading.ThreadState.StopRequested:
case System.Threading.ThreadState.SuspendRequested:
case System.Threading.ThreadState.WaitSleepJoin:
Trace.Write("known thread State");
break;

default:
Trace.Write("Unknown thread State");
break;
}

but I always end up in the default case.

Do you know what is going on please?

thank you.
 
Michael,

The ThreadState enumeration is a bitmask, meaning that you can combine
those values to get other valid values.

In this case, it is a combination of the Background flag, as well as the
Unstarted flag.

Hope this helps.
 
The ThreadState enumeration is a bitmask, meaning that you can combine
those values to get other valid values.

In this case, it is a combination of the Background flag, as well as the
Unstarted flag.

Hope this helps.

Yes it certainly does!

Thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top