从应用程序取消对Web服务的调用 [英] Cancelling call to web-service from application

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

问题描述

我有一个Winform应用程序,它具有两个按钮GetData和Close.在GetData上,我从Web服务检索一些数据,而关闭"仅关闭对话框.我在单独的线程上调用Web服务.该线程是类实例变量.如果从Web服务获取数据花费的时间太长,并且用户单击关闭",我想取消对该Web服务的调用,然后关闭对话框.

I have a winform app that has two buttons GetData and Close. On GetData I retrieve some data from a web-service whereas Close just closes the dialog. I am calling the web-service on a separate thread. This thread is class instance variable. If getting data from web-service is taking too long and user click on close, I want to cancel that call to web-service and just close the dialog.

仅通过在线程实例上调用abort来取消对该Web服务的调用的最佳方法是什么?其他任何想法/最佳做法也都欢迎.

What is the best way of cancelling that call to web-service, by just calling abort on thread instance? Any other idea/best practices are welcome too.

推荐答案

您不能取消它.一旦放置了webservice调用,即使调用线程被中止,它也将被执行.

You can not cancel it. Once the webservice call is placed then it will get executed even if the calling thread is aborted.

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

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