我有以下情况: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