• AutoResetEvent




            AutoResetEvent autoEvent 
    = new AutoResetEvent(true);        
            
    public void DowlLoadIds()
            {
                
    bool f = autoEvent.Set();
                
    for (int i = 0; i < 30; i++)
                {
                    
    //System.Threading.Thread t = new Thread(delegate() { DownIdCallBack(autoEvent); });
                    
    //t.Start();
                    TimerCallback timerDelegate = new TimerCallback(DownIdCallBack);
                    System.Threading.Timer t 
    = new System.Threading.Timer(timerDelegate, autoEvent, 0200);
                }
            }

            
    int i = 0;
            
    private void DownIdCallBack(object o)
            {
                var autoEvent 
    = (AutoResetEvent)o;
                autoEvent.WaitOne();
                
    //System.Threading.Interlocked.Increment(ref i);
                i++;
                
    if (i > 20)
                {
                    i 
    = 0;
                    autoEvent.Reset();
                    
    //autoEvent.WaitOne();
                    return;
                }
                
    //Trace.WriteLine(System.DateTime.Now.ToString());
                Trace.WriteLine(i.ToString());
                autoEvent.Set();
            }
  • 相关阅读:
    ajax
    cookie
    JavaScript基本语法
    HTML css 格式布局
    HTML 表单
    html 一般标签 常用标签 表格
    WinForm——操作word文档
    WinForm进程 线程
    音乐
    注册 传值
  • 原文地址:https://www.cnblogs.com/zyip/p/1863588.html
Copyright © 2020-2023  润新知