如何取消WCF服务调用? [英] how to cancel WCF service call?

查看:25
本文介绍了如何取消WCF服务调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行时间长的WCF函数,所以我在UI中用backgraundworker调用这个函数...我想给一个取消执行的功能,所以我中止了IComunicationObject,问题是Service执行不是停止,这种情况下有没有办法停止Service执行?

I have a WCF function that is executing long time, so I call the function in UI with backgraundworker... I want to give a feature to cancel the execution, so I abort IComunicationObject, the problem is that Service execution is not stoping, Is there any way to stop Service execution in this case?

推荐答案

您可能不需要 BackgroundWorker.您可以执行 IsOneWay 操作,也可以实施 异步模式.为防止线程问题,请考虑使用 SynchronizationContext.WCF 服务编程 在解释这些方面做得很好.

You may not need a BackgroundWorker. You can either make the operation IsOneWay, or implement the asynchronous pattern. To prevent threading issues, consider using the SynchronizationContext. Programming WCF Services does a great job at explaining these.

这篇关于如何取消WCF服务调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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