Lets say I am calling some web service method that I do not control. This method takes a long time to run, and whoever developed the web service did not think to include a asynchronous version.
What is the best way to create an asynchronous wrapper for such a method in C#/winforms?
At the moment I am using a ThreadPool to run the webservice method and then calling an event when the webservice finishes. Something like this.
DoWorkAsync() {
Webservice.LongMethod()
WorkCompleteEvent()
}
However, this doesn't appear to be ideal. For example, if I try to modify the form controls from the event handler I get a warning about not doing that from a different thread etc.
Does anyone have any other suggestions for solving this problem?