“Asynchronous operations are not allowed in this context”

点点圈 提交于 2019-12-17 17:13:34

问题


I get the exception below when invoking he automagically generated async webmethods that i asked about in this post

Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to

Google search results in add Async = True in the page directive but various people have noted that this makes the page 'Blocking' (which isn't true asynchronous operation). So how do i achieve asynchronous operation while calling webservice methods.


回答1:


Check out this answer. I won't copy/paste the answers from there but I'll extend the discussion some.

The accepted answer is NOT the correct one. Since there is no 'EndInvoke' there will be a resource leak every time this method is invoked. See this discussion on why that's not okay.

What is suggested instead is to launch either a daemon thread or create whole different processes that reads from MSMQ and processes the long-running tasks there.



来源:https://stackoverflow.com/questions/9175329/asynchronous-operations-are-not-allowed-in-this-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!