“在此上下文中不允许异步操作”

发布于 2025-01-03 09:50:16 字数 438 浏览 1 评论 0原文

当调用我在 这篇文章

在此上下文中不允许异步操作。页面起始 异步操作必须将 Async 属性设置为 true 并且异步操作只能在之前的页面启动

,只需在页面指令中添加 Async = True 即可,但很多人都注意到这会使页面“阻塞” (这不是真正的异步操作)。那么如何在调用webservice方法的同时实现异步操作呢?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水水月牙 2025-01-10 09:50:16

查看此答案 。我不会从那里复制/粘贴答案,但我会扩展一些讨论。

接受的答案不是正确的答案。由于没有“EndInvoke”,因此每次调用此方法时都会发生资源泄漏。 查看此讨论了解为什么这样不行。

建议启动守护线程或创建完全不同的进程来读取 MSMQ 并处理其中的长时间运行的任务。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文