I have a method async like this:
public static async Task SendMailAsync(){
...something
}
This method is very long time to return r
There are several background jobs processing library out there. I have used hangfire for some of my projects.
But if you want to make this simple, you can use something built-in inside asp.net.
HostingEnvironment.QueueBackgroundWorkItem((ct) =>
{
SendMailAsync();
});
OtherMethod1();
OtherMethod2();
Make sure you add reference to System.Web.Hosting
You do not need SendMailAsync() to return a Task since you will not be awaiting on something. Just let the sending of email code run in background.