Heaven 要测试SQL Server 2005的镜像功能,居然要写个代码把程序停止响应!
2008-03-11 17:04
507 查看
真是BT啊...也不知道如何来做,难道是把所有的线程都Hang住么?
( 唱到:如果是这样,你不要悲伤~~~!!!)
用下面这个代码试试看看:
原因如下 (摘自 http://blog.joycode.com/xinz/archive/2004/08/22/31313.aspx ):
但是它们有细微而重要的区别,根据这个BLOG :
Thread.Sleep is a little unusual. We can take control of threads that are inside this service. But, following the tradition of Sleep on the underlying Windows operating system, we perform no pumping.
If you need to Sleep on an STA thread, but you want to perform the standard COM and SendMessage pumping, consider Thread.CurrentThread.Join(timeout) as a replacement.
( 唱到:如果是这样,你不要悲伤~~~!!!)
用下面这个代码试试看看:
1 using System; 2 using System.Threading; 3 4 public class Test { 5 public static void Main(String[] args) { 6 //Thread.CurrentThread.Sleep(500); 7 Thread.CurrentThread.Join(5000000); 8 Console.WriteLine("874 Heaven * 100"); 9 } 10 } |
Thread.Join Blocks the calling thread until a thread terminates or the specified time elapses. |
Thread.Sleep Blocks the current thread for the specified number of milliseconds. |
Thread.Sleep is a little unusual. We can take control of threads that are inside this service. But, following the tradition of Sleep on the underlying Windows operating system, we perform no pumping.
If you need to Sleep on an STA thread, but you want to perform the standard COM and SendMessage pumping, consider Thread.CurrentThread.Join(timeout) as a replacement.
相关文章推荐
- Heaven 要测试SQL Server 2005的镜像功能,居然要写个代码把程序停止响应!
- Heaven 要测试SQL Server 2005的镜像功能,居然要写个代码把程序停止响应!
- Heaven 要测试SQL Server 2005的镜像功能,居然要写个代码把程序停止响应!
- 修补程序: 错误消息后的 SQL Server 服务错误日志文件或 SQL Server 2008年的 SQL Server 2005 中停止响应:"等待闩锁时出现超时"
- SQL Server 2005高可用性之镜像功能
- SQL Server 2005安装程序,IIS功能要求警告的解决方法
- SQL Server 2005 镜像功能实现 - 转 -已验证
- SQL Server 2005 镜像功能实现
- SQL Server 2005安装程序,IIS功能要求警告的解决方法
- SQL Server 2005 镜像功能实现
- SQL Server 2005高可用性之镜像功能
- SQL Server 2005高可用性之镜像功能(http://tech.it168.com/db/s/2007-04-24/200704240837593.shtml)
- SQL Server 2005 镜像配置(三)
- VS 2010 测试功能学习(十一) - 如何用CUIT代码定位UI控件? (转)
- gcov命令_Linux gcov 命令用法详解:测试程序的代码覆盖率的工具
- c#托盘程序测试代码
- 自己编写的使时钟不连续的测试代码-fork---join_none用法以及停止线程
- 配置SQL Server 2005 Reporting Service 的订阅功能
- 汽车销量查询小助手(小程序)销量趋势图功能及代码知识分享
- SQL Server 文档整理 - 5 胸闷测试小程序^_^