I have this code:
Thread t = new Thread(() => UpdateImage(origin));
t.Name = "UpdateImageThread";
t.Start();
If method UpdateImage(origin) throw an exception, it is necessary to stop thread or it will be stoped after the exception?
Thank you!
c++exception-handlingmultithreading
I have this code:
Thread t = new Thread(() => UpdateImage(origin));
t.Name = "UpdateImageThread";
t.Start();
If method UpdateImage(origin) throw an exception, it is necessary to stop thread or it will be stoped after the exception?
Thank you!
Best Solution
If
UpdateImage
throws an exception, it is probably going to take down your whole process. Any thread that raises a top-level exception indicates a big problem. You should wrap this, for example by puttingtry
/catch
aroundUpdateImage
and doing something suitable. And yes, if an exception gets to the top of a thread, the thread is dead:(or your choice of error handling)