简体   繁体   English

“在这种情况下,不允许异步操作”

[英]“Asynchronous operations are not allowed in this context”

I get the exception below when invoking he automagically generated async webmethods that i asked about in this post 我得到调用时,他自动地产生异步webMethods的,我问了一下在下面的异常这篇文章

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 页面启动异步操作必须将Async属性设置为true,并且异步操作只能在之前的页面上启动

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). Google搜索结果在page指令中添加了Async = True ,但许多人注意到,这使页面“阻塞” (这不是真正的异步操作)。 So how do i achieve asynchronous operation while calling webservice methods. 因此,如何在调用Web服务方法时实现异步操作。

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. 由于没有“ EndInvoke”,因此每次调用此方法都会导致资源泄漏。 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. 相反,建议启动守护进程线程或创建从MSMQ读取并处理在那里长期运行的任务的完全不同的进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM