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 实例065_使用Sleep方法延迟时间
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread th = new Thread(
() =>
{
while (true)
{
Invoke(
(MethodInvoker)(() =>
{
txt_Time.Text =
DateTime.Now.ToString("F");
}));
Thread.Sleep(1000);
}
});
th.IsBackground = true;
th.Start();
}
}
}