zoukankan      html  css  js  c++  java
  • 异步

    本想用委托异步的 发现core平台不支持BeginInvoke了

    /// <summary>
        /// 异步
        /// </summary>
        public class asynchronous
        {
            public delegate Task asyns(string name);
            
            public void Action1()
            {
                Console.WriteLine("开始.......");
                Console.WriteLine("当前线程Id为:{0}",Thread.CurrentThread.ManagedThreadId);
                //Action<string> action = new Action<string>(asynAction1);
                Console.WriteLine("开始执行.......");
                for (int i = 0; i < 5; i++)
                {
                    string name = string.Format("执行异步{0}", i);
                    Task task = Task.Run(()=> Console.WriteLine("执行异步{0},当前线程为{1}", name, Thread.CurrentThread.ManagedThreadId));
                    //action.BeginInvoke(name, null, null);//core平台已经不支持该操作了
                }
            }
    
            public static void asynAction1(string name)
            {
                Console.WriteLine("执行异步{0},当前线程为{1}",name,Thread.CurrentThread.ManagedThreadId);
            }
        }
    

      

  • 相关阅读:
    5.3二叉树的运算
    hadoop namenode切换
    org.apache.hadoop.security.AccessControlException
    Hive中的日志
    命令大全详解
    python深浅copy
    awk命令
    head&tail命令
    cut命令
    理解inode
  • 原文地址:https://www.cnblogs.com/MingQiu/p/8370719.html
Copyright © 2011-2022 走看看