c# - Thread not ending possible that exceptions cause this? -


i'm starting multiple threads different things. threads have "endme" boolean variable. when try end threads setting variable , end debugger screams not end processes.

after debugging bit found out processes go "ending" part of code when "end me" variable set accordingly. exception happens , thrown.

now question is: can exception causes thread not able ended longer?

promoting comment answer since correct , might relevant.

in absence of code reproduce problem, note if communicating between threads setting boolean variable "endme", need use volatile reads , writes access variable, instance (in .net 4.5):

public class threadedworker {     bool endme = false;      public bool endsignalled { { return volatile.read(ref endme); } }      public void signalend()     {         volatile.write(ref isended, true);     } } 

or in c# versions can use volatile keyword

public class threadedworker {     volatile bool endme = false;      public bool endsignalled { { return endme; } }      public void signalend()     {         endme = true;     } } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -