async webservice
Hi I am trying to create async webmethod. Is this the right way to create it? Or could any direct me to right article.
private delegate AuthorizationUpdateResult AuthorizationUpdateDelegate(Authorizations authorization);
/// <summary>
/// The callback.
/// </summary>
/// <param name="asyncResult">The asyncResult.</param>
private AuthorizationUpdateResult AuthorizationCallback(IAsyncResult asyncResult)
{
return new AuthorizationUpdateResult();
//Do Nothing. Maybe Send Response back in future phases
}
[WebMethod]
public void AuthorizationUpdateAsync(Authorizations a开发者_Python百科uthorization)
{
AuthorizationUpdateDelegate doAuthorizationUpdateDelegate = new AuthorizationUpdateDelegate(UpdateAuthorization);
AsyncCallback callback = new AsyncCallback(AuthorizationCallback);
doAuthorizationUpdateDelegate.BeginInvoke(authorization, callback, 1239);
}
In my case, I call async methods using EventHandlers
:
MyService service = new MyService ();
service.MyServiceCompleted += new MyServiceCompletedEventHandler(this.MyServiceCompleted);
service.MyService Async();
void MyServiceCompleted(object sender, MyServiceCompletedEventArgs args)
{
}
精彩评论