I've been playing with this idea. A couple of things, I like it but.
If you put it in the business layer, the presentation layer is only going to be calling one business method, so no benefit. If you put it in the datalayer, then handling transactions can be a bit of a nightmare. So, I can't see a use for doing it this way, although I really do like the idea. On the upside I have found out a lot about the new parallel stuff in 4.5. Davy. *Si hoc legere scis nimium eruditionis habes*. On Sat, Mar 28, 2015 at 5:32 AM, Stephen Price <[email protected]> wrote: > 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* >> > >
