本文实例讲述了C#随机设置900-1100毫秒延迟的方法。分享给大家供大家参考。具体如下:
using System;using System.Threading;///<summary>/// A time delay of 900..1100 milliseconds///</summary>namespace RobvanderWoude{ class WaitASecond { static void Main( string[] args ) { // Choose a random delay between 900 //and 1100 milliseconds Random randomNums = new Random( ); int delay = randomNums.Next( 900, 1100 ); // Display the actual time delay //if ANY command line parameter was passed if ( args.Length > 0 ) { Console.WriteLine("waiting {0} milliseconds...",delay); } // Now wait... Thread.Sleep( delay ); } }}
希望本文所述对大家的C#程序设计有所帮助。
新闻热点
疑难解答