I have many threads in my application, how do I stop only one thread from them? If I use Thread.Sleep() it stops the whole application, I just want to stop a single thread. How do I do that? I am using c#.
I have many threads in my application, how do I stop only one thread
Share
When you are using
Thread.Sleep()you are stopping only thread, which called this method. If your main thread (i.e. UI thread) callsThread.Sleep(), then application freezes (actually other threads continue working, but UI is not refreshed). So, if you want to stop some thread, then:Thread.Sleep()on that threadExample (assume this code is executed on main thread):
And this is a callback (which is executed on background thread):