J'Initialisation un fil comme fil statique comme indiqué ci-dessousthread STA Abandonner Exception
Thread GenerateKeywords;
private void btnStart_Click(object sender, EventArgs e)
{
//Initializes the Test Thread
Test = new Thread(TestMethod);
//Sets the apartment state to Static
Test.SetApartmentState(ApartmentState.STA);
//Starts the GenerateKeywords Thread
Test.Start();
}
mais quand je suis ABORTING ce fil via cette méthode
private void btnStop_Click(object sender, EventArgs e)
{
if (Test != null)
Test .Abort();
}
Il est de donner exception suivante: " Une exception de première occurrence de type 'System.Threading.ThreadAbortException' s'est produite dans mscorlib.dll Le thread 0x13dc s'est terminé avec le code 0 (0x0). "
Comment se débarrasser de cette exception?
Ce n'est pas une exception, juste une notification du débogueur qu'une exception a été détectée. Ce qui est normal, Thread.Abort() injecte une exception. Ne * pas * corriger cela. –