开发者

async webservice

开发者 https://www.devze.com 2023-02-18 04:26 出处:网络
Hi I am trying to create async webmethod. Is this the right way to create it? Or could any direct me to right article.

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)
{

}
0

精彩评论

暂无评论...
验证码 换一张
取 消