在aspx,ashx页面挂起线程执行
今天测试一个页面,需要阻塞下当前执行aspx或者ashx页面的线程,发现没有sleep方法,不怎么懂线程编程方面的知识,晓不得什么情况。
后面看到join方法也能阻塞挂起当前执行aspx,ashx页面的线程,就直接join就行了,贴出代码,留以后备用,O(∩_∩)O哈哈~
原创文章,转载请注明出处:在aspx,ashx页面挂起线程执行
后面看到join方法也能阻塞挂起当前执行aspx,ashx页面的线程,就直接join就行了,贴出代码,留以后备用,O(∩_∩)O哈哈~
+展开
-C#
<%@ WebHandler Language="C#" Class="sleep" %>
using System;
using System.Web;
using System.Threading;
public class sleep : IHttpHandler
{
public void hello() { }
public void ProcessRequest(HttpContext context)
{
System.Threading.Thread.CurrentThread.Join(10000);
context.Response.Write(DateTime.Now.ToString());
}
public bool IsReusable {
get {
return false;
}
}
}
using System;
using System.Web;
using System.Threading;
public class sleep : IHttpHandler
{
public void hello() { }
public void ProcessRequest(HttpContext context)
{
System.Threading.Thread.CurrentThread.Join(10000);
context.Response.Write(DateTime.Now.ToString());
}
public bool IsReusable {
get {
return false;
}
}
}
加支付宝好友偷能量挖...
原创文章,转载请注明出处:在aspx,ashx页面挂起线程执行