S
Simple Simon
Hi, excuse the long post and plz read on
My web application needs to upload a .csv & .zip file, as well as,
import the .csv into a (Sql2000) table and unzip the .zip file to a
directory on the web server every day. Since I don't want the
application to time-out, I'm putting all this into a Server-Side
Asynchronous Web Method.
I've starting out by writing this test web service:
public delegate string GetListingsAsyncStub(int DelayInSeconds);
public string GetListings(int DelayInSeconds)
{
if (DelayInSeconds > 0)
{
System.Threading.Thread.Sleep(DelayInSeconds * 1000);
}
return "Success";
}
public class MyState
{
public object previousState;
public GetListingsAsyncStub asyncStub;
}
[WebMethod]
public IAsyncResult BeginGetListings(int DelayInSeconds, AsyncCallback
callback, object asyncState)
{
GetListingsAsyncStub stub = new
GetListingsAsyncStub(GetListings);
MyState ms = new MyState();
ms.previousState = asyncState;
ms.asyncStub = stub;
return stub.BeginInvoke(DelayInSeconds, callback, ms);
}
[WebMethod]
public string EndGetListings(IAsyncResult asyncResult)
{
MyState ms = (MyState)asyncResult.AsyncState;
return ms.asyncStub.EndInvoke(asyncResult);
}
And this is in my Page_Load page that will be scheduled to run:
string ReturnValue;
IAsyncResult AsyncResult;
ImportService service = new ImportService();
Response.Write("Started: " + DateTime.Now.ToString() + "<br>");
AsyncResult = service.BeginGetListings(10, null, null);
ReturnValue = service.EndGetListings(AsyncResult);
Response.Write("Ended: " + DateTime.Now.ToString() + "<br>");
Response.Write(ReturnValue);
What I'm seeing is, the page waits for the ten seconds to load. Does
ne1 see the obvious(to you) reason?
TIA,
~Gordon
My web application needs to upload a .csv & .zip file, as well as,
import the .csv into a (Sql2000) table and unzip the .zip file to a
directory on the web server every day. Since I don't want the
application to time-out, I'm putting all this into a Server-Side
Asynchronous Web Method.
I've starting out by writing this test web service:
public delegate string GetListingsAsyncStub(int DelayInSeconds);
public string GetListings(int DelayInSeconds)
{
if (DelayInSeconds > 0)
{
System.Threading.Thread.Sleep(DelayInSeconds * 1000);
}
return "Success";
}
public class MyState
{
public object previousState;
public GetListingsAsyncStub asyncStub;
}
[WebMethod]
public IAsyncResult BeginGetListings(int DelayInSeconds, AsyncCallback
callback, object asyncState)
{
GetListingsAsyncStub stub = new
GetListingsAsyncStub(GetListings);
MyState ms = new MyState();
ms.previousState = asyncState;
ms.asyncStub = stub;
return stub.BeginInvoke(DelayInSeconds, callback, ms);
}
[WebMethod]
public string EndGetListings(IAsyncResult asyncResult)
{
MyState ms = (MyState)asyncResult.AsyncState;
return ms.asyncStub.EndInvoke(asyncResult);
}
And this is in my Page_Load page that will be scheduled to run:
string ReturnValue;
IAsyncResult AsyncResult;
ImportService service = new ImportService();
Response.Write("Started: " + DateTime.Now.ToString() + "<br>");
AsyncResult = service.BeginGetListings(10, null, null);
ReturnValue = service.EndGetListings(AsyncResult);
Response.Write("Ended: " + DateTime.Now.ToString() + "<br>");
Response.Write(ReturnValue);
What I'm seeing is, the page waits for the ten seconds to load. Does
ne1 see the obvious(to you) reason?
TIA,
~Gordon