【发布时间】:2012-09-16 18:44:16
【问题描述】:
我想每天在我的 Windows 服务中检查许可证
我尝试使用 DispatcherTimer 但不工作
这就是我试图做的
public OIMService()
{
InitializeComponent();
_dispatcherTimer = new DispatcherTimer();
this.ServiceName = "OIMService";
if (!System.Diagnostics.EventLog.SourceExists("OIM_Log"))
{
EventLog.CreateEventSource("OIM_Log", "OIMLog");
}
EventLog.Source = "OIM_Log";
EventLog.Log = "OIMLog";
_sc = new ServiceController("OIMService");
_helpers = new ValidationHelpers();
StartTimer();
}
private void StartTimer()
{
_dispatcherTimer.Tick += new EventHandler(DispatcherTimerTick);
_dispatcherTimer.Interval = new TimeSpan(0, 0, Convert.ToInt32(time));
_dispatcherTimer.IsEnabled = true;
_dispatcherTimer.Start();
}
private void DispatcherTimerTick(object sender, EventArgs e)
{
var helpers = new ValidationHelpers();
if (!helpers.IsValid())
this.Stop();
}
【问题讨论】:
-
不是重复这个问题是关于我如何检查 Windows 服务中的许可证而不是关于 DespatcherTimer
-
@tito11,它要么完全重复,要么完全缺少示例代码(我看到零行代码以某种方式与“许可证...”相关)
标签: c# windows-services