I am writing an API in C# and I want to provide both synchronous and asynchronous versions of the publicly available methods. For example, if I have the following function:
public int MyFunction(int x, int y)
{
// do something here
System.Threading.Thread.Sleep(2000);
return x * y;
}
how can I create an asynchronous version of the above method (perhaps BeginMyFunction and EndMyFunction)? Are there different ways to achieve the same result, and what are the benefits of the various approaches?