Unity - A计划(一年有效期) 扫二维码继续学习 二维码时效为半小时

(61评价)
价格: 2170.00元
c#编程高级_委托方式发起线程_该操作不被平台支持
homodeus发起了问答2018-12-25
1
回复
592
浏览

在此行出现异常     IAsyncResult res = a.BeginInvoke("/html", 100, null, null);

System.PlatformNotSupportedException:“Operation is not supported on this platform.”

 

以下源码

 

using System;
using System.Threading;

namespace _20_线程_委托方式发起线程
{
    class Program
    {
        
        //一般我们会为比较耗时的操作开启单独的线程去执行,比如以下操作
        static int Test(string i, int j)
        {
            Console.WriteLine("www.kk.com" +i+ j);
            Thread.Sleep(100);//让当前线程休眠(暂停线程执行)单位ms
            return 100;
        }
        static void Main(string[] args)
        {
            Func<string, int, int> a = Test;
            IAsyncResult res = a.BeginInvoke("/html", 100, null, null);
            Console.WriteLine("main");
            while (res.IsCompleted == false)
            {
                Console.Write(".");
                Thread.Sleep(10);
            }
            int done = a.EndInvoke(res);
            Console.WriteLine(done);
            Console.ReadKey();

        }
    }
}

所有回复
发表回复
你还没有登录,请先 登录或 注册!