Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

abort thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
one2001boy@yahoo.com - 22 Sep 2005 05:07 GMT
Hello,

is there a function to abort the running thread (thread-a) from another
thread (thread-b)?

thanks.
Lloyd Dupont - 22 Sep 2005 05:34 GMT
what about:
thread.Abort() ?

> Hello,
>
> is there a function to abort the running thread (thread-a) from another
> thread (thread-b)?
>
> thanks.
Mike P - 22 Sep 2005 06:51 GMT
> Hello,
>
> is there a function to abort the running thread (thread-a) from another
> thread (thread-b)?
>
> thanks.

Sure sounds like a big time design problem if you have to resort to aborting
threads. How about providing a mechanism for orderly thread shutdown? It's
really pretty simple to do......

Mike P
Alper AKCAYOZ - 22 Sep 2005 14:21 GMT
Hello,
You may look to below code-snipp that is written C++.NET. There are 2
functions (Func_A, Func_B), and they are being run by 2 threads (Thread_A,
Thread_B). Thread_B will abort the Thread_A. Pay attention to
"ThreadAbortException" class. It is required at Func_A not to throw an
exception when Thread_B is aborting the Thread_A.

//Func_A is running by Thread_A
private:
void Func_A( )
{
 try
 {
    // Do your work here ...
 }
 catch(ThreadAbortException *exp)
 {
   /*No need to do a work. Maybe write a message into log file.*/
 }
 catch(Exception *exp)
 { /*Catch other exceptions.*/ }
}

//Func_B is running by Thread_B.
void Func_B( )
{
 try
 {
     ...
     Thread_A->Abort();
     Thread_A->Join();  
     ...      
}
catch(ThreadAbortException *exp)
{...}
catch(Exception *exp)
{}
}

Signature

~~~~~~~~~~~~~~~~~~~
İyi Çalışmalar
Alper AKÇAYÖZ (Bil Muh)

Wish You Good Work
Alper AKCAYOZ (Bil Muh)

> Hello,
>
> is there a function to abort the running thread (thread-a) from another
> thread (thread-b)?
>
> thanks.
Alper AKCAYOZ - 28 Sep 2005 09:46 GMT
> Hello,
> You may look to below code-snipp that is written C++.NET. There are 2
> functions (Func_A, Func_B), and they are being run by 2 threads (Thread_A,
> Thread_B). Thread_B will abort the Thread_A. Pay attention to
> "ThreadAbortException" class. It is required at Func_A not to throw an
> exception when Thread_B is aborting the Thread_A.

I would like to correct my word. Use "ThreadAbortException" class to catch
this type of expection when other thread aborts one thread. Aborted thread
will throw this exception and if you catch "ThreadAbortException" class, you
may do specific works when thread is aborted.
Signature

~~~~~~~~~~~~~~~~~~~
İyi Çalışmalar
Alper AKÇAYÖZ (Bil Muh)

Wish You Good Work
Alper AKCAYOZ (Bil Muh)


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.