Multithreading PerformSelector单触穿线

Multithreading PerformSelector单触穿线,multithreading,css-selectors,timer,xamarin.ios,Multithreading,Css Selectors,Timer,Xamarin.ios,使用此语句将立即调用选择器,而不是从现在起6秒 this.PerformSelector(myStartWaitForSoundSelector, null, 6.0f); 有人知道如何让它延迟工作吗 我在调用的函数中使用了thread.Sleep(6000),但整个应用程序锁定了6秒钟 谢谢。您可以使用NSTimer: NSTimer.CreateScheduledTimer(new TimeSpan(0, 0, 6), delegate { Cons

使用此语句将立即调用选择器,而不是从现在起6秒

this.PerformSelector(myStartWaitForSoundSelector, null, 6.0f);
有人知道如何让它延迟工作吗

我在调用的函数中使用了
thread.Sleep(6000)
,但整个应用程序锁定了6秒钟


谢谢。

您可以使用NSTimer:

NSTimer.CreateScheduledTimer(new TimeSpan(0, 0, 6),
                    delegate { Console.WriteLine("teste"); });
这将导致委托内的代码在6秒后运行,而不会阻塞主应用程序线程