如何使用系统时间终止应用程序(C#2008) [英] how to terminate an application (C# 2008) using the system time
本文介绍了如何使用系统时间终止应用程序(C#2008)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想终止我使用Visual Studio 2008使用系统时间编写的程序.例如,我希望程序在3.00pm之前终止.帮助!!!!!!!!!
i want to terminate a program i wrote using visual studio 2008 by using the system time. for example i want program to terminate itself by 3.00pm. HELP!!!!!!!!!
推荐答案
DateTime whenToCallCloseMyApplication;
Timer timer = new Timer((whenToCallCloseApplication - DateTime.Now).Milliseconds);
timer.Elapsed += CloseMyApplication;
并非100%精确,但足够接近.并且一旦设置了计时器,调用CloseMyApplication
时系统时钟就不会更改.
Not 100% precise, but close enough. And once the timer has been set changing the system clock wont change when CloseMyApplication
is invoked.
这篇关于如何使用系统时间终止应用程序(C#2008)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文