using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread th = new Thread(ChangeTextBox);
th.IsBackground = true;
th.Start();
}
public bool flag = true;
public void ChangeTextBox()
{
this.Invoke(new Action(() =>
{
this.textBox1.Width = (int)(this.textBox1.Width * (flag ? 2 : 0.5));
flag = !flag;
}));
}
}
}
多线程中操纵UI
最新推荐文章于 2021-11-30 20:30:00 发布