Silverlight Web Service

Below is the code that I used to use web surfing in SilverLight.

private void button1_Click(object sender, RoutedEventArgs e)
{
      BasicHttpBinding bind = new BasicHttpBinding();
      EndpointAddress endpoint = new EndpointAddress("http://loalhost/Service.asmx");
      ServiceSoapClient client = new ServiceSoapClient(bind, endpoint);
      client.RunHelloCompleted += new EventHandler<RunHelloCompletedEventArgs>(client_RunQwinCompleted);
      client.RunHelloAsync(command);
 }

 void client_RunHelloCompleted(object sender, RunHelloCompletedEventArgs e)
 {
      txtProcess.Text=Process(e.Result);
 }

I want to know how, after running RunHelloAsync (Command), I want to get the returned result without going to the Completed event. Please advise me. thank.

+3
source share
1 answer

The simple answer is: you cannot. Everything in Silverlight is asynchronous, so after a call client.RunHelloAsync(command)there is no way to block and wait for the result.

Long answer: There are ways to simulate working with calls synchronously, but calls are still being made asynchronously. Check out this thread for more answers.

+3
source

Source: https://habr.com/ru/post/1757943/


All Articles