Locked Async and Entity Framework

Todas las respuestas

  • sábado, 22 de octubre de 2011 13:59
     
     Respondida Tiene código

    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
  • domingo, 04 de diciembre de 2011 16:32
    Moderador
     
     Respondida
    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.
  • 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:33
     
     
    Thanks for the link, gread post