How to Know is a thread is alive

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I know that there is a method isalive to know if a thread is alive in the
framework.
But how do i know if a thread is alive and running in compact framework.

Is there any similar method in .net cf.....??

Thanks in Advance,
Murthy
 
Hi Murthy,

Although it's a workaround by importing win32_CE API,
it's indeed a workable code segment....

Assume you use C#

using System.Threading;
using System.Runtime.InteropServices; // for using other APIs

[DllImport("coredll.dll")]
public unsafe static extern bool GetExitCodeThread(UInt32 hThread,
UInt32 * lpExitCode);

UInt32 eCode;

GetExitCodeThread((uint)Thread.CurrentThread.ManagedThreadId,
&eCode);

if (eCode == 0x00000103) // constant of STILL_ALIVE
{
MessageBox.Show("Thread still alive");
}


[Note] ..... to check "allow unsafe code" when you build your project.....
 
Hello

We've just made a boolean which we set at the beginning to True and at the
end to False
Friend Treadisrunning as boolean = False

Then you have access to the Bool at any place...
 
Back
Top