在此行出现异常 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();
}
}
}