How to pause / resume a thread in C#

Posted by Anuraj on Sunday, June 16, 2013

.Net ASP.Net Windows Forms

Here is the code snippet which will help you to pause / resume a thread using ManualResetEvent class. Both Suspend() and Resume() methods are deprecated in .Net Framework. So both of these methods not recommended to use.

private ManualResetEvent _manualResetEvent = new ManualResetEvent(true);

var thread = new Thread(() =>
    while (true)
        //Do the work here

And to pause the thread, you can use


And to resume you can use


You can find more details about ManualResetEvent in MSDN

Happy Programming.

Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon

BMC logoBuy me a coffee

Copyright © 2018 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub