Question

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.

Était-ce utile?

La solution

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)
{

}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top