Hi, I use NHibernate 3.
Recently I tried upgrading a web app to include some async/await in some areas. The tried and tested method of fetching the Session context has been: https://gist.github.com/Plasma/a41afdc023aea1da7a36 for supporting web/console apps. This example is all around the Internet. This works fine up until now. - Problem - When I await a certain method, that method is being executed on a threadpool thread, and thus has lost its NHibernate context. This is a problem for AspNet MVC4 async methods especially because I don't see an obvious way to carry across the context from the initial HTTP request thread, to the threadpool thread that is processing the async command. Obviously, I don't want to manually pass it around everywhere and burden my code in each spot. Is there a way for the NHibernate context to be detected in this case? I'm really puzzled by this. HttpContext, CallContext, CallContext.LogicalGetData perhaps may help, but I feel suspicious about using it since I don't understand it properly. This is ignoring the problem as well of perhaps multiple async methods being run at once (eg, Task.WaitAll(task1, task2)) where both would end up needing separate NHibernate sessions (or run one after each other). How are people facing this problem? Thanks -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
