public Task DoSomething()
{
return Task.CompletedTask;
}
No need for the async.
If you're using an older version of .NET, use this:
public Task DoSomething()
{
return Task.FromResult(0);
}
If you find you need to return a result but you still dont need to await anything, try;
public Task<Result> DoSomething()
{
return Task.FromResult(new Result())
}
or, if you really want to use async (not recommended);
public async Task<Result> DoSomething()
{
return new Result();
}
{
return Task.CompletedTask;
}
No need for the async.
If you're using an older version of .NET, use this:
public Task DoSomething()
{
return Task.FromResult(0);
}
If you find you need to return a result but you still dont need to await anything, try;
public Task<Result> DoSomething()
{
return Task.FromResult(new Result())
}
or, if you really want to use async (not recommended);
public async Task<Result> DoSomething()
{
return new Result();
}
1 Comments
Share great information about your blog , Blog really helpful for us .
ReplyDeleteReference: https://v8web.com/