TNA
TNA

Reputation: 616

Silverlight Web Service

Below is the code i used to consume web servcie 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 a way that after i run RunHelloAsync(Command), I want to get the returned result without going to Completed event. Please advise me. thank you.

Upvotes: 3

Views: 177

Answers (1)

Stephan
Stephan

Reputation: 5488

Simple answer : You can't. Everything in Silverlight is Asynchronous so there is no way to block after the client.RunHelloAsync(command) call and wait for the result.

Long answer : There are ways to simulate working with calls in a synchronous fashion, but the calls still being made asynchronously. Take a look at this thread for a few more answers.

Upvotes: 3

Related Questions