I have an interface which forces me to implement an (async) Task:
namespace Microsoft.Owin.Security.Infrastructure
{
public interface IAuthenticationTokenProvider
{
..
Task CreateAsync(AuthenticationTokenCreateContext context);
..
}
}
I want to implement this method, but I'm not awaiting anything. Although I have to await something or return some task, otherwise my code does not compile.:
public class MyImplementation: IAuthenticationTokenProvider
{
public async Task CreateAsync(AuthenticationTokenCreateContext context)
{
/// do something synchronously.
await something here? ??
}
}
My question is: How would I implement this method without doing something asynchronously? I've have found a couple of solutions (await task.Yield(), or await Task.Run(() => {})), yet I can't fully understand what would be the correct implementation and why.
CreateAsyncmethod does. If it's always quick, then that's fine, and you can just suppress the warning for that bit of code.