C# Task Beispiel

private async void button2_Click(object sender, EventArgs e)
{
    label1.Text = "Running Task";
    button2.Enabled = false;
    string result = await WaitAsynchronouslyAsync();
    label1.Text = result;
    button2.Enabled = true;
}

public async Task<string> WaitAsynchronouslyAsync()
{
    await Task.Delay(10000);
    return "Finished";
}

Beliebige Methode async aufrufen

await Task.Run(() => UpdateCheck());


private void UpdateCheck()
{
    ...
}


Datenschutzerklärung | Impressum