I have a method async like this:
public static async Task SendMailAsync(){
...something
}
This method is very long time to return r
SendMailAsync will run synchronously until first await block inside.
Marking method as "async" doesn't actually make it magically to run asynchronously. You have to use await inside that method
Your code is synchronous, to run it in another thread without changing signature or code in your SendMailAsync you can use. But ideally you should rewrite SendMailAsync to use async API of MailSender
var resultTask = Task.Run(async () => await SendMailAsync());
OtherMethod1();
OtherMethod2();
var result = await resultTask;