C#随机设置900-1100毫秒延迟的方法
本文实例讲述了C#随机设置900-1100毫秒延迟的方法。分享给大家供大家参考。具体如下:
usingSystem; usingSystem.Threading; ///<summary> ///Atimedelayof900..1100milliseconds ///</summary> namespaceRobvanderWoude { classWaitASecond { staticvoidMain(string[]args) { //Choosearandomdelaybetween900 //and1100milliseconds RandomrandomNums=newRandom(); intdelay=randomNums.Next(900,1100); //Displaytheactualtimedelay //ifANYcommandlineparameterwaspassed if(args.Length>0) { Console.WriteLine("waiting{0}milliseconds...",delay); } //Nowwait... Thread.Sleep(delay); } } }
希望本文所述对大家的C#程序设计有所帮助。