Share:

Async Task In C# | Async And Await Keywords | Saatody | Amit Padhiyar

Today we will discuss about async and await keyword. And will know some examples about Task.

private async void MyTask()
{
    await Task.Run(() =>
    {
        // Code Here
    });
}

Avoid use of void. use Task or Task<return_type>.

private async Task MyTask()
{
    await Task.Run(() =>
    {
        // Code Here
    });
}

It can use for non return value.

private async Task<int> MyTask()
{
    await Task.Run(() =>
    {
        // Code Here
    });

    return int;
}

Returns int values.

Comments

Popular posts from this blog

Basic Audio Operations With MP3 And Wave Files Using NAudio C#

Get Color From Pixel C# WPF | Saatody | Amit Padhiyar

Create Drag And Drop Operation Between DevExpress GridControl And Custom WPF UI | Saatody | Amit Padhiyar