Sleep a thread

You can include a timeout when calling Join, either in milliseconds or as a TimeSpan.

It then returns true if the thread ended or false if it timed out.

Thread.Sleep pauses the current thread for a specified period:


using System;
using System.Threading;

class ThreadTest
{
    static void Main()
    {
        Thread.Sleep(TimeSpan.FromHours(1));  // sleep for 1 hour
        Thread.Sleep(500);  // sleep for 500 milliseconds
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.