In. net1.x, asynchronous WebService is generally called by calling the beginxx method corresponding to method XX. The process is similar to the use of asynchronous delegation. For more information, click here.
In. net2.0 (specifically VS 2005), an example of asynchronous WebService asynchronous call method is provided:
Void Dosomethingtest ()
{
Localhost. Service = New Windowsapp. localhost. Service ();
Service. helloworldcompleted + = New Windowsapp. localhost. helloworldcompletedeventhandler (service_helloworldcompleted );
// Do Asyn calling here
Service. helloworldasync ();
}
Void Service_helloworldcompleted ( Object Sender, windowsapp. localhost. helloworldcompletedeventargs E)
{
If (E. Error = Null )
{
MessageBox. Show (E. Result );
}
Else
{
MessageBox. Show (E. Error. Message );
}
}
ServerCode
[WebService (namespace = " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
Public Class Service: system. Web. Services. WebService
{
Public Service () {
}
[Webmethod]
Public String Helloworld () {
Return "Hello World";
}
}
It's easy. No moreAsynccallback and iasyncresult are two annoying things. The called code becomes concise and elegant, and a strongly typed return value ("Hello World" in the preceding example) can be obtained from E. result "). However, if you are interested, you can check the referance. CS file generated by VS 2005, which is much more complicated than the referance. CS file generated by vs 2003. The system. componentmodel. asynccompletedeventargs and system. Threading. sendorpostcallback (delegate) are not found in. Net 1.x. It is estimated that more than the WebService client is used. Have time to study again.