WCF RIA 服务在单线程上等待?
有人可以解释一下为什么会发生这种情况吗?
- 使用 WCF Ria 服务的 Silverlight 4 应用程序
SL 应用程序调用
StartLongOperation
[Invoke]
操作。
由于与外部组件的同步问题,服务器端代码中存在Thread.Sleep(30 * 1000)
。SL 应用程序调用
GetStatus
(标准查询)操作。 这些调用似乎在服务器端被阻止,并正在等待StartLongOperation
完成。为什么?
我假设在服务器端,StartLongOperation
运行一个工作线程,并且每次调用 GetStatus
都将在单独的工作线程上运行。客户端调用是异步的,因此 SL 触发 StartLongOperation
,然后继续轮询 GetStatus
。但在 StartLongOperation
完成之前,GetStatusCompleted
不会被触发。
Can someone explain me why this is happening?
- Silverlight 4 application using WCF Ria Services
SL app calls
StartLongOperation
[Invoke]
operation.
Due to synchronization issues with external components there is aThread.Sleep(30 * 1000)
in the server-side code.SL app calls
GetStatus
(standard query) operation.
These calls appear to be blocked server-side and are waiting for theStartLongOperation
to complete. Why??
I was assuming that serverside, the StartLongOperation
runs an a worker thread and each call to GetStatus
would run on a seperate worker thread. Client-side the calls are async so SL fires off the StartLongOperation
and then continues to poll the GetStatus
. But the GetStatusCompleted
doesn't get fired until the StartLongOperation
has completed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于所有 Silverlight 网络通信都发生在 UI 线程上,因此一次只能发生一个 WCF 调用。这意味着您的 StartLongOperation 必须完成,然后客户端将启动 GetStatus 调用。如果您想测试此行为,请启动 Fiddler。您会发现 Silverlight 不会向 GetStatus 方法发送 HTTP 请求,直到它首先从服务器获取 StartLongOperation 响应。
所以问题不在于服务器端。这是 Silverlight 的限制。
Since all Silverlight network communication happens on the UI thread, only one WCF call can happen at a time. Meaning your StartLongOperation has to complete, and then the client will start the GetStatus call. If you want to test this behavior, fire up Fiddler. You will find that Silverlight will not send an HTTP request to the GetStatus method until it first gets a StartLongOperation response from the server.
So the problem isn't server-side. It's a limitation of Silverlight.