我有以下情況:ASP.net C#返回JS警報從另一個線程
在Default.aspx.csvoid Button1_Click(Object Sender, EventArgs e)
{
new Thread(() =>LongProcessFunction()).Start();
// I am running this function in a new thread so the end user does not wait till the end of the process
}
public void LongProcessFunction()
{
//some code with long process
// When done alert the user no matter what he's doing on the website.
System.Web.UI.ScriptManager.RegisterStartupScript(this, GetType(), "Alert","alert('Function is Complete')" , true);
}
的問題是,我需要這個警報腳本,爲最終用戶。 我假設它在另一個線程上運行並且沒有顯示。
長時間運行多久?如果時間不長,您可以發出ajax請求。 – 2012-04-12 14:26:13
這是一個非常長的數據導出功能,需要38秒才能達到40,而用戶並不需要等待它,他將數據導出到另一個數據庫! – user1329310 2012-04-12 14:28:13