👨🏼‍💻개발/C#

C# - setTimeout 구현

Janger 2022. 8. 28. 18:39
728x90
방법 1.
Task.Delay(delay).ContinueWith((task) => { /* Code */ });

 

방법 2.
public void setTimeout(Action TheAction, int Timeout)
{
    Thread t = new Thread(
        () =>
        {
            Thread.Sleep(Timeout);
            TheAction.Invoke();
        }
    );
    t.Start();
}

 

 

출처: 

https://stackoverflow.com/questions/4331149/winforms-equivalent-of-javascript-settimeout

 

Winforms equivalent of javascript setTimeout

Is there a simple solution/idea/strategy to create a setTimeout equivalent function in a WinForms app. I'm primarily a web developer but am not sure how I'd go about this in a WinForms App. Basical...

stackoverflow.com

 

728x90