Async and Entity Framework
-
lunes, 17 de octubre de 2011 12:57
Not sure if this is the right place but i'll try :-)
I plan to use async and entity framework. But there's a lack of async methods. Are there some ideas / Framworks to optimize the handling?
Also there's a post in Uservoice, perhaps someone also needs this and likes to post?
Todas las respuestas
-
sábado, 22 de octubre de 2011 13:59
Hi Gentlehag,
You can just wrap your executions in a task and await it like this:
var result = await Task<IEnumerable<MyDataModel>>.Factory.StartNew(new Action(() => { return GetListOfMyDataModel() }));
Assuming that the method GetListOfMyDataModel communicates with the database and it is very time consuming, this can be a way to do it.
Hope this helps!
Mark good replies as helpful and correct ones as answers! - http://blog.filipekberg.se- Marcado como respuesta Stephen Toub - MSFTMicrosoft Employee, Moderator domingo, 04 de diciembre de 2011 16:33
-
domingo, 04 de diciembre de 2011 16:32Moderador
Diego Vega from the Entity Framework team at Microsoft responded about async support in EF at http://social.msdn.microsoft.com/Forums/en-MY/async/thread/a78ed205-b19c-4b3a-bc69-ff1bf7595230.- Marcado como respuesta Stephen Toub - MSFTMicrosoft Employee, Moderator domingo, 04 de diciembre de 2011 16:33
-
miércoles, 21 de diciembre de 2011 10:32
Thanks for your reply.
Thats the way I'm currently doing it. But I think it isn't the same thing, is it ?
When using the async capatibilities of the Sql Api , no new threads are created, they just use some kind of statemachines, do they ?
When Using Task.Factory.StartNew new threads can be created (depending on the schulder), right ?I don't feel so sure about these things, perhaps someone can clarify the exact behavior ?
-
miércoles, 21 de diciembre de 2011 10:33Thanks for the link, gread post

