C#怎样判断时钟走了几秒

来源:百度知道 编辑:UC知道 时间:2024/07/07 20:28:56
比如判断当窗体运行5秒后弹出来个对话框?
C#中怎样实现呢??

日 就算你不会可以用更笨的办法呀(但是这样只能记录60秒,如果想弄更长时间就用上面的吧!!)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication66
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
label1.Text = DateTime.Now.ToString();

}

private void timer1_Tick(object sender, EventArgs e)
{
label2.Text = DateTime.Now.ToString();
DateTime a = Convert.ToDateTime(label1.Text );
DateTime b = Convert.ToDateTime(label2.Text );
string c = Convert.ToStrin