I have this async method in C# code:
public async Task DoYourThingAsync()
{
....
}
Now, for some legacy code I have to offer a synchronous version of this method, similar to how for example HttpClient
offers synchronous and async versions of the same method. I do not want to copy-paste my code to a second method, so I did this:
public int DoYourThing()
{
return DoYourThingAsync().Result;
}
Question: is this the correct way to accomplish this?
No comments:
Post a Comment