“Asynchronous operations are not allowed in this c

2019-01-15 20:47发布

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条回答
手持菜刀,她持情操
2楼-- · 2019-01-15 21:30

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.

查看更多
登录 后发表回答