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.
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.
You can not cancel it. Once the webservice call is placed then it will get executed even if the calling thread is aborted.
精彩评论