using System;
using System.Threading;
namespace TimerRunDemo
{
class Program
{
/// <summary>
/// 声明一个线程实例
/// </summary>
public static Thread mythread;
#region 计算剩余时间
private static int CompareDate(string synchroDateStr)
{
long nowDT = DateTime.Now.Ticks / 10000;
DateTime synchroDate = Convert.ToDateTime(synchroDateStr);
long synchroDT = synchroDate.Ticks / 10000;
int sleepDT = -1;
if (synchroDT > nowDT)
{
sleepDT = Convert.ToInt32(synchroDT - nowDT);
}
if (sleepDT != -1)
{
Console.WriteLine("当前时间的毫秒数:" + nowDT);
Console.WriteLine("执行同步的时间的毫秒数:" + synchroDT);
Console.WriteLine("剩余时间的毫秒数:" + sleepDT);
Console.WriteLine("剩余时间的秒数:" + sleepDT / 1000);
Console.WriteLine(
C# .net 定时器,多线程实现定时器
最新推荐文章于 2024-07-27 18:37:30 发布