Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do you make a delay before repeating a function in vscode?

static void Main( ) {


Function( );


static void Function( ) {

Console.WriteLine("Function Called");



  • Oops, I meant before calling.

  • HNJHNJ Member

    Is it C#, if yes, you will have to use Coroutines

    static void Main() {    
    IEnumerator Function()  {
        yield return new WaitForSeconds(5f); //5f is the seconds to wait
        Console.WriteLine("Function Called");
  • I tried that. it works in visual studio when opened with unity, but doesn't work with visual studio code

  • You can use Thread.Sleep:


Sign In or Register to comment.