0
protected void Button1_OnClick(object sender, EventArgs e)
{
    FineTuneDB();// Long Task running in db
    SendSMStoAllClients();// Using Twolio API to send sms to all client long task

    lblText.Text = "Button click is completed our system threads working on your request";
}

Is this possible that on button click I can response to client and independent long task going on separately.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
SOF User
  • 7,590
  • 22
  • 75
  • 121

1 Answers1

1

If you don't care about whether task is completed or not, you call FineTuneDB method like this.

Action fineTuneDB = FineTuneDB;
fineTuneDB.BeginInvoke(null, null);

Asynchronous Method Invocation

Updated:

Action<int, string> fineTuneDB = FineTuneDB;
fineTuneDB.BeginInvoke((int)Session["id"], 
   Session["name"].ToString(), null, null);

// Your method will be like this
public void FineTuneDB(int id, string)
{

}
Win
  • 61,100
  • 13
  • 102
  • 181
  • sorry here I got one issue using this technique it works fine but I found that sessions values are not available because httpcontext.current is null durign finetuneDB method – SOF User Mar 13 '13 at 22:10
  • Yes, it is true. If you want to pass the variables, use the second method. – Win Mar 14 '13 at 13:56