C # error System.Threading.ThreadAbortException: Aborting thread

Source: Internet
Author: User

Reference: http://www.cnblogs.com/chendaoyin/archive/2013/06/27/3159211.html

1. Turn on a sub-thread

1 // to open a child thread, the child thread invokes the method 2 New Thread (Method); 3 true ; 4 th. Start ();

2. Thread-handling functions

1  Public voidMethod ()2 {3     Try4     { }5     Catch(Exception ex)6     { 7 MessageBox.Show (ex. ToString (());8     }9     finallyTen     { One Th.abort (); A     } -}

The Exception ex here captures the system exception, but the thread uses the Abort method to close the thread during execution, prompting

System.Threading.ThreadAbortException: Aborting thread the error.

Workaround:

1  Public voidMethod ()2 {3     Try4     { }5      catch(ThreadAbortException ex) 6     {7     //do not operate8     }9     Catch(Exception ex)Ten     {  One MessageBox.Show (ex. ToString (()); A     } -     finally -     { the Th.abort (); -     } -}

C # error System.Threading.ThreadAbortException: Aborting thread

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.