社区
C#
帖子详情
如何实时显示系统时间
vcshox
2006-10-31 08:55:52
程序界面上要实时显示到毫秒的系统时间,要如何处理?用TIMER好像刷新速度太慢
...全文
644
11
打赏
收藏
如何实时显示系统时间
程序界面上要实时显示到毫秒的系统时间,要如何处理?用TIMER好像刷新速度太慢
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
11 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
打赏红包
灰太狼
2006-11-01
打赏
举报
回复
毫秒級的刷新用控件可能不行,要自己寫thread來做了。
luohy527
2006-11-01
打赏
举报
回复
private void timer1_Tick(object sender, EventArgs e)
{ label1.Text = DateTime.Now.ToLongTimeString() +" "+DateTime.Now.Millisecond.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
dyw31415926
2006-11-01
打赏
举报
回复
程序界面上要实时显示到毫秒的系统时间,要如何处理?用TIMER好像刷新速度太慢--
----------------------------------------------------------------
这要看你用什么控件来显示了,就我个人看法,用系统自带的控件恐怕都不能实现毫秒级别的更新频率,得采用一些技巧才行,如贴图等,或是采用一些伪毫秒表(就是实际上不是0.001秒刷新一次的,只是显示时有3位小数而已,这应该是最常见的)
song530061187
2006-11-01
打赏
举报
回复
用time控件吧,时间间隔可以调,可精确到毫秒(一般都够用了),又方便。
Onlyzhugf
2006-11-01
打赏
举报
回复
用线程:
public delegate void Show();
private Thread PThread;
private Thread FThreadNoticeInfo;
private Mutex FMutex;
public event Show onShow;
private void Frm102_Load(object sender, System.EventArgs e)
{
FThreadNoticeInfo = new Thread(new System.Threading.ThreadStart
(CheckLatestNoticeInfo));
FThreadNoticeInfo.Start();
}
private void CheckLatestNoticeInfo()
{
while (true)
{
//時間を設定は3分です
Thread.Sleep(300000);
FMutex.WaitOne();
try
{
Invoke(onShow, null);
}
finally
{
FMutex.ReleaseMutex();
}
}
}
void onShowDo()
{
System.DateTime currentTime=new System.DateTime();
//1.2 取当前年
int Year=currentTime.Year;
//1.3 取当前月
int Month=currentTime.Month;
//1.4 取当前日
int Day=currentTime.Day;
//1.5 取当前时
int Hour=currentTime.Hour;
//1.6 取当前分
int Minute=currentTime.Minute;
//1.7 取当前秒
int Second=currentTime.Second;
//1.8 取当前毫秒
int Millisecond秒=currentTime.Millisecond;
string time=Convert.ToString(Year)+"-"+Convert.ToString(Month)+"-"+Convert.ToString(Day)+" "+Convert.ToString(Hour)+":"+Convert.ToString(Minute)+"."+Convert.ToString(Millisecond)
}
copico
2006-11-01
打赏
举报
回复
用Timer吧
可以很准的,用线程很容易出异常
dyw31415926
2006-11-01
打赏
举报
回复
zhangzengping(张增平)
你也可以用线程: 做一个死循环: 里面 Sleep(1000);-
solitude119() (
加个time控件的 刷新时间改成1000 就快了
-----------------------
这叫秒表,不叫毫秒表吧
liujia_0421
2006-10-31
打赏
举报
回复
可以使用Stopwatch
看下csdn吧...
oolongTea
2006-10-31
打赏
举报
回复
//.NET2.0 Stopwatch 类
http://msdn2.microsoft.com/zh-cn/library/system.diagnostics.stopwatch.aspx
zhangzengping
2006-10-31
打赏
举报
回复
TIMER 应该不会很慢:
pulic CurrentTime = datatime.now:
timer_tick(.....sender,.......e)
{
CurrentTime.addSecond(1) // 大约如此,有点忘了! 不好意思!
UI's control .text =datatime.now:
}
你也可以用线程: 做一个死循环: 里面 Sleep(1000);
solitude119
2006-10-31
打赏
举报
回复
加个time控件的 刷新时间改成1000 就快了
相关推荐
C#多线程
实时
显示
系统
时间
【VS2008源码】
C#多线程
实时
显示
系统
时间
C#多线程
实时
显示
系统
时间
C#多线程
实时
显示
系统
时间
C#多线程
实时
显示
系统
时间
C#多线程
实时
显示
系统
时间
Android(安卓)应用开发技术 Android(安卓)应用开发技术 开发BroadcastReceiver.pptx
学习目标;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;示例
实时
显示
系统
时间
;知识点小结;感谢您的学习
Qt
实时
显示
系统
时间
Qt
实时
显示
系统
时间
实时
获取并
显示
系统
时间
实时
获取并
显示
系统
时间
,html文件
用JS实现
实时
显示
系统
时间
用JS实现
实时
显示
系统
时间
发帖
C#
C#
.NET技术 C#
复制链接
扫一扫
10.8w+
社区成员
64.2w+
社区内容
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
帖子事件
创建了帖子
2006-10-31 08:55
社区公告
让您成为最强悍的C#开发者