Model/CountdownTimer.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace CustomTimers
{
public class CountdownTimer : CustomTimer
{
private int _HourLatch = 0;
private int _MinuteLatch = 0;
private int _SecondLatch = 0;
private int _MillisecondLatch = 0;
//-----------------------------------------------
// Private member functions
//-----------------------------------------------
private int UpdateInternalTimeRunning = 0;
private void UpdateInternalTime ()
{
// Prevent Reentry
if (Interlocked.Exchange (ref UpdateInternalTimeRunning, 1) == 0)
{
//DateTime currentTime = DateTime.Now;
//_Millisecond -= (currentTime.Millisecond - _SystemTimeLatched.Millisecond);
//_Second -= (currentTime.Second - _SystemTimeLatched.Second);
//_Minute -= (currentTime.Minute - _SystemTimeLatched.Minute);
//_Hour -= (currentTime.Hour - _SystemTimeLatched.Hour);
//_SystemTimeLatched = DateTime.Now;
_DiagnosticsStopWatch.Stop ();
TimeSpan timeElapsed = _DiagnosticsStopWatch.Elapsed;
long totalMilliseconds = Convert.ToInt64 (timeElapsed.TotalMilliseconds);
long intervalInMs = GetIntervalInMilliseconds ();
long totalTime = Convert.ToInt64 (
(double) totalMilliseconds / (double) intervalInMs)
* intervalInMs;
_Millisecond = _MillisecondLatch - (int) (totalTime % 1000);
totalTime = totalTime / 1000;
_Second = _SecondLatch - (int) (totalTime % 60);
totalTime = totalTime / 60;
_Minute = _MinuteLatch - (int) (totalTime % 60);
totalTime = totalTime / 60;
_Hour = _HourLatch - (int) (totalTime % 60);
FindEffectivTime ();
if (_Millisecond == 0 && _Second == 0 &&
_Minute == 0 && _Hour == 0)
{
if (State != TimerStates.Stopped)
{
后面还有 64 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
