Sobes.tech
Junior — Middle

Millist tulemust tagastab meetodi asünkroonne kutse?

sobes.tech AI

Vastus AI-lt

The asynchronous call of a method in C# usually returns an object of type Task or Task<T>. This object represents a promise of the operation's completion in the future.

  • If the method does not return a result, it returns Task.
  • If the method returns a result of type T, it returns Task<T>, which contains the result upon completion.

Example:

async Task<int> GetDataAsync()
{
    await Task.Delay(1000); // simulation of an asynchronous operation
    return 42;
}

Calling GetDataAsync() immediately returns a Task<int>, and the result can be obtained via await or through the Result property (the latter blocks the thread).