zoukankan      html  css  js  c++  java
  • C#等待子线程执行完毕

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    
    namespace ConsloeApp1
    {
    
        class Program
        {
            static ManualResetEvent manualRestEventA = new ManualResetEvent(false);
            static ManualResetEvent manualRestEventB = new ManualResetEvent(false);
            static void Main(string[] args)
            {
    
    
                Task taskA = new Task(new Action(() => {
                    for (int i = 0; i < 100; i++)
                    {
                        Console.WriteLine("*******************************************************************");
    
                    }
                    manualRestEventA.Set();
                }));
    
                Task taskB = new Task(new Action(() => {
                    for (int i = 0; i < 1000; i++)
                    {
                        Console.WriteLine("____________________________________________________________________");
                    }
    
                    manualRestEventB.Set();
                }));
    
                taskA.Start();
                taskB.Start();
    
                manualRestEventA.WaitOne();
                manualRestEventB.WaitOne();
    
                Console.WriteLine("Synchornolyze Done");
    
                Console.ReadKey();
            }
        }
    }
    

      

  • 相关阅读:
    事务
    handler
    codeforces 27E Number With The Given Amount Of Divisors
    暑期实践日志(五)
    暑期实践日志(四)
    暑期实践日志(三)
    暑期实践日志(二)
    暑期实践日志(一)
    数论 UVALive 2756
    数论 UVALive 2911
  • 原文地址:https://www.cnblogs.com/sclu/p/12818884.html
Copyright © 2011-2022 走看看