VS:System.PlatformNotSupportedException: ‘Operation is not supported on this platform;

VS:System.PlatformNotSupportedException: ‘Operation is not supported on this platform.‘

01 .NET Core版本问题,从3.1换了5.0没用

VS:System.PlatformNotSupportedException: ‘Operation is not supported on this platform.‘

02 改用Task.Run

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

   //01-01 异步 无返回值
        static void Thread_44_AsynVoid_BeginInvoke()//不支持BeginInvoke
        {
     
            Action<int> a = Thread_44_1;//通过委托开启新线程
            int para = 100;//参数
            a.BeginInvoke(para, null, null);//a.BeginInvoke(回调方法,传入回调方法的参数);
            
            Console.WriteLine("当前方法名:" + MethodBase.GetCurrentMethod().Name);
        }
        static void Thread_44_AsynVoid_TaskRun()//支持Task.Run
        {
     
            Action<int> a = Thread_44_1;
            int para = 1;//参数
            var res = Task.Run(() => a.Invoke(para));//开启线程

            //先打印Main,还是先打印新线程中的方法,是由系统决定的(顺序随机)
            Console.WriteLine("当前方法名:" + MethodBase.GetCurrentMethod().Name);
        }
        static void Thread_44_1(int para)
        {
     
            Console.WriteLine("当前方法名:" + MethodBase.GetCurrentMethod().Name + ",参数:" + para);
        }

你可能感兴趣的:(Unity,C#,Siki)