问题描述
嘿伙计们,你好,我希望你会好起来我的问题是有什么方法可以在没有计时器的情况下在C#中制作数字时钟,因为当我使用计时器,所以我的应用程序工作非常慢我想显示系统日期和时间无论如何,我的应用程序没有计时器,所以请帮助我怎么做呢
谢谢
我尝试过:
label2.text = system.datetime.now.tostring();
Hey Guys, How are you i hope you will be fine well my question is there any way to make digital clock in C# without timer because when I use timer so my application working very slow I want to show system date and time in my application without timer is there anyway so please help me how can I do it
Thanks
What I have tried:
label2.text = system.datetime.now.tostring();
推荐答案
一个提示:使用线程,而不是计时器,在线程体也使用System.DateTime。即使使用计时器,也总是从这个结构中抽出时间,从不依赖计时器的计时。 (但是避免使用计时器,一般来说,线程更容易,更安全,更正确;使线程主体循环调用System.Threading.Thread.Sleep,其休眠时间少于一秒。
One hint: use thread, not a timer and, in the thread body also use System.DateTime. Even with timer, always take time from this structure, never rely on timer's timing. (But avoid a timer, a thread is much easier, safer and more correct, in general; make thread body a cycle calling System.Threading.Thread.Sleep with the sleep time less then a second.
这篇关于如何在没有定时器的情况下用C#制作数字时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!