5

使用此语句会立即调用选择器,而不是从现在开始 6 秒。

this.PerformSelector(myStartWaitForSoundSelector, null, 6.0f);

有谁知道如何让它延迟工作?

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

谢谢。

4

1 回答 1

8

您可以使用 NSTimer:

NSTimer.CreateScheduledTimer(new TimeSpan(0, 0, 6),
                    delegate { Console.WriteLine("teste"); });

这将导致委托内的代码在 6 秒后运行,而不会阻塞主应用程序线程。

于 2009-12-21T22:32:59.637 回答