Normally i was creating each thread per action i wanted to do multithreaded. I was doing it like that:
private Thread threadForWycena;
private void someMethod() {
threadForWycena = new Thread(globalnaWycena);
threadForWycena.Start();
}
Then when user wanted to close one of the gui's i was checking for this thread and if it was on i was dissalowing to close it.
private void ZarzadzajOplatamiGlobalneDzp_FormClosing(object sender, FormClosingEventArgs e)
{
if (threadForWycena.IsAlive) {
MessageBox.Show("Wycena jest w toku. Zamknięcie okna jest niemożliwe.", "Brak wyjścia :-)");
e.Cancel = true;
}
}
Is there a way to do it using ThreadPool, so that i can prevent window closing and i can tell user which thread is still alive and what's it's doing?