Zhenya Posted April 3, 2022 Share Posted April 3, 2022 How do I delay the execution of any method? So that when I called some method, it would not be executed immediately, but after n time. Link to comment
rohit.gonsalves Posted April 4, 2022 Share Posted April 4, 2022 Use Spin Locks. Rohit Link to comment
Tessalator Posted April 4, 2022 Share Posted April 4, 2022 There are different approaches depending on your needs. If you want to trigger a method and continue (non-blocking), run the method as a Task, Main(){ _ = Task.Run(async() => { await Task.Delay(1000); //1 sec. YourMethod(); }); } General Info: Overview of synchronization primitives | Microsoft Docs 1 Link to comment
ThaDoggFather Posted January 2, 2023 Share Posted January 2, 2023 On 4/4/2022 at 11:36 PM, Tessalator said: await Task.Delay(1000); //1 sec. Hello, hate to be a bother but Unigine tells me that 'Task' doesn't exist in the current context (been trying for ages to find a debounce method). Link to comment
Tessalator Posted January 4, 2023 Share Posted January 4, 2023 (edited) Do you have a reference to System.Threading? I don't know that Tasks (used like above) would be good for things like debounce. You could be spinning up a lot of threads. Rohit's Spin Locks, etc. are lower level and better suited. Edited January 4, 2023 by Tessalator Link to comment
Recommended Posts