zoukankan      html  css  js  c++  java
  • C# Task的使用

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;


    namespace TaskExam
    {
        class Program
        {
            static void Main(string[] args)
            {
                var parent = new Task(ParentTask);
                parent.Start();

                Thread.Sleep(2000);
                Console.WriteLine(parent.Status);
                Thread.Sleep(4000);
                Console.WriteLine(parent.Status);
                Console.Read();
            }


            static void ParentTask()
            {
                Console.WriteLine("task id {0}", Task.CurrentId);
                var child = new Task(ChildTask);
                child.Start();
                Thread.Sleep(1000);
                Console.WriteLine("Parent start Child");
                
            }


            static void ChildTask()
            {
                Console.WriteLine("Child");
                Thread.Sleep(5000);
                Console.WriteLine("Child finished");
            }
        }
    }
  • 相关阅读:
    linux驱动模板
    Matlab的安装
    级数模型
    多元思维
    一级指针和二级指针
    Biology 053: Visualization of Digestive Enzymes
    Biology 052: Digestion Experiment
    Biology 06: Metabolism and Nutrition
    线性回归之电力预测
    python之产生随机数
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434776.html
Copyright © 2011-2022 走看看