I have a thread that opens a form of type MyMessageAlert. This form is a popup window that is opened when I call it. It has a timer which calls a method CloseWindow() after 30 seconds.
m_messagAlert = new MyMessageAlert();
ParameterizedThreadStart thStart = new ParameterizedThreadStart(m_messagAlert.setMessage);
Thread thread = new Thread(thStart);
thread.Start(strMessage); //at this point, the MyMessageAlert form is opened.
I have defined a list of type thread:
public List<Thread> m_listThread;
Each time that I create a thread, I add it to my list:
m_listThread.Add(thread);
When I close the application, I want that the form of type MyMessageAlert that was opened, will be closed immediately (without waiting 30 seconds). Problem is that I can't make it stop!
I tried to kill it by going over the list with a loop using the Abort() function:
foreach (Thread thread in m_listThread)
{
if (thread.IsAlive)
thread.Abort();
}
But it doesn't help.