C#实现实时时间显示
通过C#实现实时时间显示:
源代码如下:
using System;
using System.Collections.Generic;using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace ceshi4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
new Thread(() =>
{
while (true)
{
try
{
label1.BeginInvoke(new MethodInvoker(() =>
label1.Text = DateTime.Now.ToString()));
}
catch { }
Thread.Sleep(1000);
}
}) { IsBackground = true }.Start();
}
private void Form1_load(object sender, EventArgs e)
{
}
}
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
