Yeah, generally speaking, if you think you understand something, you must
have it wrong.

Also, as soon as you comprehend something, someone will change it. Just
assume you have no idea and be done with it. Run with it until someone
complains about it. :)

On Sat, Mar 28, 2015 at 12:17 PM, Greg Keogh <[email protected]> wrote:

> Folks, I have an existing library with lots of traditional non-async
> methods in it, and I want to provide async versions of the old methods.
> Would you consider this to be a simple and trustworthy way of getting this
> done?
>
> public Thing GetThing(int key)
> {
>   // This is the existing method
>   return ...
> }
>
> public Task<Thing> GetThingAsync(int key)
> {
>   return Task.Run(() =>
>   {
>      return GetThing(key);
>   }
> }
>
> So I just make matching pairs where the old methods are just wrapped in
> Task.Run(...). It seems too easy. This is Framework 4.5, and I have a vague
> recall that Task.Run doesn't work this easily in 4.0 and it's a bit more
> verbose.
>
> *Greg K*
>

Reply via email to