来源:https://wwwdev.cn/article/20101217/in-aspx-ashx-page-suspend-thread.aspx
今天测试一个页面,需要阻塞下当前执行aspx或者ashx页面的线程,发现没有sleep方法,不怎么懂线程编程方面的知识,晓不得什么情况。
后面看到join方法也能阻塞挂起当前执行aspx,ashx页面的线程,就直接join就行了,贴出代码,留以后备用,O(∩_∩)O哈哈~
<%@ 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; } } }