开发者

Work with WCF methods Async Call Result

开发者 https://www.devze.com 2023-02-16 01:15 出处:网络
I am using Silverlight 4 with WCF Services for my database interaction . I am facing one problem. Function all in silverlight application.

I am using Silverlight 4 with WCF Services for my database interaction . I am facing one problem.

Function all in silverlight application.

    ServiceReference1.WCFSLServicesClient wc = new ServiceReference1.WCFSLServicesClient();

    private void button1_Click(object sender, RoutedEventArgs e)
    {
       _wait = new ManualResetEvent(false);
       wc.SayHelloCompleted += new EventHandler<ServiceReference1.SayHelloCompletedEventArgs>(wc_SayHelloCompleted);开发者_C百科

       wc.SayHelloAsync("Mr. X");
//wait untill the call finish and then move next like     

       //Here I want to do some thing with result of above call.  And then proceed to next task . 

    }

    String Name = String.Empty;
    void wc_SayHelloCompleted(object sender, ServiceReference1.SayHelloCompletedEventArgs e)
    {
       Name =e.Result;
    }

But all methods calls in Silver light are Async so I am not able to Get this out.


Put whatever it is you want to do into another method and call that method from your Completed Handler.

void wc_SayHelloCompleted(object sender, ServiceReference1.SayHelloCompletedEventArgs e)
{
   Name =e.Result;

   MyNewMethod(Name);
}
0

精彩评论

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