i have a bit different scenario .
i m using calling fucntions asynchronously using begin invoke and
endinvoke ...some time i need to cancel that without waiting for
their completion and close the application normally...
i was asking the quesion in that context .
i hope you got my point now
Process currentProcess = Process.GetCurrentProcess();
foreach( Thread thread in currentProcess.Threads ) { if( thread.ManagedThreadId.Equals( threadId ) ) { // We found you thread! And abort it. thread.Abort(); } }
Note: when you are using .NET Framework 1.x you there isn't a ManagedThreadId property but just a Id property.
Obtaining a Thread from ThreadID
optyler
i m using calling fucntions asynchronously using begin invoke and endinvoke ...some time i need to cancel that without waiting for their completion and close the application normally...
i was asking the quesion in that context .
i hope you got my point now
Any help will be highly apprecisted
thanks
tabish.
Paul200607
int threadId = 0xFF;
Process currentProcess = Process.GetCurrentProcess();
foreach( Thread thread in currentProcess.Threads )
{
if( thread.ManagedThreadId.Equals( threadId ) )
{
// We found you thread! And abort it.
thread.Abort();
}
}
Note: when you are using .NET Framework 1.x you there isn't a ManagedThreadId property but just a Id property.
Tarek Ahmed Ismail