"异步操作是不允许在这种情况下" [英] "Asynchronous operations are not allowed in this context"

查看:167
本文介绍了"异步操作是不允许在这种情况下"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到调用的时候,他自动地生成异步webMethods的,我问了一下在<一个下面的异常href=\"http://stackoverflow.com/questions/9075354/legacy-asmx-webservice-how-to-use-automagically-generated-async-method/9075560#9075560\">this帖子

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

异步操作在此上下文中允许的。页开始
  异步操作必须具有异步属性设置为true
  和异步操作只能在页面上之前开始

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

在添加谷歌搜索结果异步=真在页面指令,但不同的人都注意到,这使得页面的'阻塞'(其中是不正确的异步操作)。那么,如何实现异步操作,同时呼吁web服务的方法。

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.

推荐答案

查看<一个href=\"http://stackoverflow.com/questions/672237/running-an-asynchronous-operation-triggered-by-an-asp-net-web-page-request\">this回答。我不会复制/粘贴从那里的答案,但我会延长讨论一番。

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

接受的答案是不正确的。由于没有EndInvoke会将有一个资源泄漏每次调用此方法的时间。 <一href=\"http://stackoverflow.com/questions/532722/is-endinvoke-optional-sort-of-optional-or-definitely-not-optional\">See这个讨论的,为什么这是不行的。

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.

什么是建议而不是是启动为守护线程或创建一个从MSMQ读取和处理长期运行的任务在那里。

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.

这篇关于&QUOT;异步操作是不允许在这种情况下&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆