문제

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.

도움이 되었습니까?

해결책

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

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top