C#WPF应用程序调度未来的时间和日期 [英] C# WPF Application Scheduling Future Time and Date

查看:166
本文介绍了C#WPF应用程序调度未来的时间和日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助创建一个WPF应用程序,其中用户将来安排一个DATE,将来安排一个TIME,然后调用某个方法或执行其他操作,比如看不见。设置间隔后,我不关心它的作用。除了如何跟踪用户设置的时间间隔外,我还拥有所有必需的功能。我使用日历工具来检索用户数据。我创建了自己的时间选择器,供用户选择时间。现在我只需要一种根据系统时钟测量时间和日期然后做某事的方法。我读过的所有内容都说使用Dispatcher类来跟踪时间。还有其他课吗?或者在WPF中有更好的方法吗?

I am needing help creating a WPF application where the user schedules a DATE in the future and a TIME in the future to where it will then call some method or do something else like go invisible. I am not concerned with what it does after the interval is set. I have all the needed functionality except for how to keep track of the time interval set by the user. I use the calendar tool to retrieve the user data. I created my own time picker for the user to pick the time. Now I just need a way of measuring that time and date against the system clock to then do something. Everything that I have read says to use the Dispatcher class to keep track of time. Is there another class? Or is there a better way in WPF to do this?

推荐答案

不,如果您只是需要追踪经过的实际时间,请使用 System.Diagnostics.Stopwatch

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx [ ^ ]。



这是最准确的方式测量可用时间。



由于我不能确定我真的能从这个问题中理解它的情景和最终目的,这只是一个建议。目前尚不清楚追踪是什么意思。无论如何,无论出于何种原因,了解测量经过时间的最佳方法非常重要。



-SA
No, if you simply need to track elapsed "real" time, use System.Diagnostics.Stopwatch:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx[^].

This is the most accurate way of measuring time available.

As I cannot be sure I really can understand the scenario and the ultimate purpose of it from this question, this is just a suggestion. It''s not clear what is is meant by "tracking". Anyway, it''s important to know the best way of measuring elapsed time, for whatever reason.

—SA


这篇关于C#WPF应用程序调度未来的时间和日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆