Files
CapMachine/CapMachine.Wpf/Services/SysService.cs
2024-07-28 22:59:11 +08:00

50 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CapMachine.Wpf.Services
{
/// <summary>
/// 系统资源
/// </summary>
public class SysService : BindableBase
{
public SysService()
{
// 创建一个定时器设置间隔时间为2000毫秒即2秒
CurTimer = new System.Timers.Timer(5000);
CurTimer.AutoReset = true;
// 设置Elapsed事件处理程序
CurTimer.Elapsed += CurTimer_Elapsed;
// 启动定时器
CurTimer.Start();
}
private void CurTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
{
CurDateTime=DateTime.Now;
}
/// <summary>
/// 定时器
/// </summary>
private System.Timers.Timer CurTimer { get; set; }
private DateTime _CurDateTime;
/// <summary>
/// 当前时间信息
/// </summary>
public DateTime CurDateTime
{
get { return _CurDateTime; }
set { _CurDateTime = value; RaisePropertyChanged(); }
}
}
}