<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } -->
Nevermind, I did some research and found out that there are two ways to do this nowadays.
without having to change and project settings to create the reference.cs with thee old Begin / End Async methods.
1. OneWay calling of a WebMethod.
2. Asynchronously calling a WebMethod (page does not render though, until the WebMethod returns)
1. OneWay calling of a WebMethod.
Introduction
Sometimes you may want to call a webservice method, but not want to wait for a reply.
This can be accomplished by making use of the OneWay SoapDocumentMethod attribute.
[SoapDocumentMethod(OneWay = true)]
[WebMethod]
public void LengthyFunctionOneWay(int milliseconds)
{
System.Threading.Thread.Sleep(milliseconds);
}
private wsLengthy.Service1 proxy = new wsLengthy.Service1();
protected void btnCallLengthyWebServiceOneWay_Click(object sender, EventArgs e)
{
proxy.LengthyFunctionOneWay(20000);
}
2. Asynchronously calling a WebMethod
Introduction
This article will discuss how to create and asynchronously call a webservice webmethod from an Asp.NET application. Please note that this method will asynchronously call the webmethod, however the web page that called the webmethod will not render until the webmethod has successfully returned.
Note: Asynchronously calling a webmethod does not mean that a web page will return immediately.
[WebMethod]
public void LengthyFunctionOneWay(int milliseconds)
{
System.Threading.Thread.Sleep(milliseconds);
return "Lengthy Function Returned after (" +
milliseconds.ToString() +
") milliseconds.";
}
<%@ Page Language="C#" AutoEventWireup="true" Async="true" ...
using WebApplication1.wsLengthy;
private wsLengthy.Service1 proxy = new wsLengthy.Service1();
protected void btnCallLengthyWebService_Click(object sender, EventArgs e)
{
proxy.LengthyFunctionCompleted +=
new LengthyFunctionCompletedEventHandler(OnLengthyCompleted);
proxy.LengthyFunctionAsync(20000);
}
void OnLengthyCompleted(Object source, LengthyFunctionCompletedEventArgs e)
{
Response.Write(e.Result.ToString());
}
I.W Coetzer