gpt4 book ai didi

multithreading - PerformSelector 单点触控线程

转载 作者:行者123 更新时间:2023-12-04 06:49:31 28 4
gpt4 key购买 nike

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

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

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

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

谢谢。

最佳答案

您可以使用 NSTimer:

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

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

关于multithreading - PerformSelector 单点触控线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1942544/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com