zoukankan      html  css  js  c++  java
  • C# 用ManulResetEvent 控制Thread的 Suspend、Resume

    class Program
        {
            static void Main(string[] args)
            {
                Thread thread = new Thread(Work);
                thread.Start();
    
                Console.ReadLine();
                Pause();
                Console.ReadLine();
                Resume();
                Console.ReadLine();
                
                Pause();
                Console.ReadLine();
                Resume();
            }
    
            static ManualResetEvent wait_handle = new ManualResetEvent(true);
    
            
    
            static void Pause()
            {
    
                wait_handle.Reset();
            }
    
            static void Resume()
            {
                wait_handle.Set();
            }
    
            static private void Work()
            {
                while(true)
                {
                    
                    wait_handle.WaitOne();
    
                    Console.WriteLine("running...");
                }
            }
        }
  • 相关阅读:
    z-index优先级小结
    如何消除img间的默认间隙
    text-align和vertical-align
    HTTP
    HTTP
    HTTP
    HTTP
    ES6标准入门
    ES6标准入门
    ES6标准入门
  • 原文地址:https://www.cnblogs.com/akiing/p/8383768.html
Copyright © 2011-2022 走看看