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
Post a Comment