⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 button delay 实现时间延迟功能
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace button1Delay
{
    public partial class Form1 : Form
    {
        public delegate void 我的委托();//声明一个委托 
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            new System.Threading.Thread(new System.Threading.ThreadStart(新线程)).Start();//创建一个新的线程并启动 

        }
        public void 设置文字()
        {
            button1.Text = "Hello";
        }

        public void 新线程()
        {
            System.Threading.Thread.Sleep(2000);//线程休眠2秒 
            button1.BeginInvoke(new 我的委托(设置文字));//在button1所在线程上执行“设置文字” 


        } 

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -