Hi,
I would like to use an asynchronous page, but this is my first time for this.
I would like to loop from 1 to 5000000 and do it asyncronously. With the
code below, the loop is executing asyncronously, but my problem is that the
render method of the page, is executing before the looping ends.
How its possible dont render until the loop is finished? What could be the
best approach for this example?
Here is the code:
public delegate void LooperAsyncHandler();
public partial class _Default : System.Web.UI.Page
{
private Looper looper;
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
looper = new Looper(5000000);
LooperAsyncHandler handler = new LooperAsyncHandler(looper.DoLoop);
handler.BeginInvoke(EndLooping, null);
}
}
private void EndLooping(IAsyncResult ar)
{
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
}
}
Thanks for the info.
Kind Regards.
Josema.
|