[英]How to invoke a function but don't wait to finish - ASP.NET
I got one page where i do some file manipulation, and when file is done, i need to upload to amazon s3.我在一页上进行了一些文件操作,文件完成后,我需要上传到 amazon s3。 Sometimes file can be large, so user on submit need to wait too much.
有时文件可能很大,所以提交的用户需要等待太多。 How can i make something like
我怎样才能做出类似的东西
Easiest way to do this:最简单的方法:
ThreadPool.QueueUserWorkItem(YourUploadMethod);
There is some comment below arguing with this, so I wrote this:下面有一些评论与此争论,所以我写了这个:
protected void Page_Load(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(YourUploadMethod);
Response.Redirect("http://google.com");
}
public void YourUploadMethod(object state)
{
Thread.Sleep(7000);
}// breakpoint: I was redirected to google and then debugger stopped me here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.