Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

asynchronous method call

  Asked By: Thomas    Date: Jul 29    Category: Asp.net    Views: 2310

I want to call a void method asynchronously from an asp.net page, because I don't want my users having to wait for some time-consuming task the page performs.
I'm having troubles implementing this. I have a sample witch calls a method that returns a string (www.dotnetbips.com/displayarticle.aspx?id=126) but I can't get it to work with a void method.

After that I'm not sure how to call the method without waiting for the result (EndInvoke) from my asp.net page.
Below my (simplified) code:

using System;
using System.Runtime.Remoting.Messaging;

public class IM

public delegate void IMDelegate();
public void IM(string message)
// do some time consuming MSN message sending, witch I don't want the client having to wait for

public IAsyncResult BeginIM(string message, AsyncCallback ac, Object state)
IMDelegate cd = new IMDelegate(this.IM);
IAsyncResult result=cd.BeginInvoke(ac,state);

return result;

public void EndIM(string message, IAsyncResult result)
IMDelegate cd = (IMDelegate) ((AsyncResult)result).AsyncDelegate;
object o=cd.EndInvoke(result);



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on asynchronous method call Or get search suggestion and latest updates.