1

In a asmx webservice i use with c# class library project after adding the web reference to the project which exposes the WebMethods inside the service there are multiple method names for example,

In my service i have a webmethod named GetCategories but the intellisense also shows GetCategoriesAsync

Is this a asynchronous call to the same webmethod? If so how can i invoke this asynchronous method any examples ?

Deeptechtons
  • 10,945
  • 27
  • 96
  • 178

1 Answers1

1

You can call the method the same as you call the regular method, you should also sign up a function to the method completion event so that upon a response you could continue the proccess.

this is an example I found

protected void Button1_Click
(object sender, EventArgs e)
{
     BookSupplier1.WebService1 supplier1 = new BookSupplier1.WebService1();

     supplier1.GetCostCompleted += new BookSupplier1.GetCostCompletedEventHandler(supplier1_GetCostCompleted);

     supplier1.GetCostAsync(TextBox1.Text, BulletedList1);

}


void supplier1_GetCostCompleted(object sender, BookSupplier1.GetCostCompletedEventArgs e)
{
     if (e.Error != null)
     {
         throw e.Error;
     }
     BulletedList list = (BulletedList)e.UserState;
     list.Items.Add("Quote from BookSupplier1 : " + e.Result.ToString("C"));
}

Example Link

Mithir
  • 2,355
  • 2
  • 25
  • 37