UpdateNow() private method

private UpdateNow ( ) : void
return void
コード例 #1
0
        private static void SetDateTime()
        {
            int retryCount = 30;

            Console.WriteLine("Waiting for a valid date & time...");

            // if SNTP is available and enabled on target device this can be skipped because we should have a valid date & time
            while (DateTime.UtcNow.Year < 2018)
            {
                // force update if we haven't a valid time after 30 seconds
                if (retryCount-- == 0)
                {
                    Console.WriteLine("Forcing SNTP update...");

                    Sntp.UpdateNow();

                    // reset counter
                    retryCount = 30;
                }

                // wait for valid date & time
                Thread.Sleep(1000);
            }

            Console.WriteLine($"We have valid date & time: {DateTime.UtcNow.ToString()}");

            DateTimeAvailable.Set();
        }
コード例 #2
0
ファイル: NetworkHelpers.cs プロジェクト: karayakar/Samples-1
        private static void SetDateTime()
        {
            Console.WriteLine("Setting up system clock...");

            // if SNTP is available and enabled on target device this can be skipped because we should have a valid date & time
            while (DateTime.UtcNow.Year < 2018)
            {
                Sntp.UpdateNow();

                Console.WriteLine("Waiting for valid date time...");
                // wait for valid date & time
                Thread.Sleep(1000);
            }

            DateTimeAvailable.Set();
        }