Q:

C# Delaying without sleep

public void delay()
    {

        var t = async delegate { await Task.Delay(15000)};
        t.Wait();
    }

    private void btnStart_Click(object sender, EventArgs e)
    {
        disable();
        txtUrl.Text = "Link1";
        webBrowser1.Navigate("Link1");
        delay();

        txtUrl.Text = "Link2";
        webBrowser1.Navigate("Link2");
        delay();
        txtUrl.Text = "Link3";
        webBrowser1.Navigate("Link3");

I'm trying to make an app that surfs three links automatically every 15 seconds, but this does not work. This kind of delay functions cause sleep when I run it. 

A:

You should use async await keyword like this 
public Task delay()
{
    return Task.Delay(15000);
}

private async void btnStart_Click(object sender, EventArgs e)
{
    disable();
    txtUrl.Text = "Link1";
    webBrowser1.Navigate("Link1");
    await delay();

    txtUrl.Text = "Link2";
    webBrowser1.Navigate("Link2");
    await delay();

    txtUrl.Text = "Link3";
    webBrowser1.Navigate("Link3");
    // ...
}

