I am initializing a thread as static thread as shown below
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();
}
but when I am aborting this thread via this method
private void btnStop_Click(object sender, EventArgs e)
{
if (Test != null)
Test .Abort();
}
It is giving following exception : " A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll The thread 0x13dc has exited with code 0 (0x0). "
How to get rid of this exception??