namespace DelegateTest { internal delegate void ProgressDelegate(int value); public partial class Form1 : Form { public Form1() { InitializeComponent(); this.progressBar1.Maximum = 200000; } private void button1_Click(object sender, EventArgs e) { Thread thread = new Thread(SetValue); thread.IsBackground = true; thread.Start(); } private void SetValue() { for (int i = 1; i <= 200000; i++) { SetValue(i); } } private void SetValue(int i) { if (InvokeRequired) { Invoke(new ProgressDelegate(SetValue), i); return; } progressBar1.Value = i; } } }//为什么第一次InvokeRequired就是true//Invoke(new ProgressDelegate(SetValue), i); SetValue是什么意思?//InvokeRequired==false时执行 progressBar1.Value = i;?//请详细解释下这个函数里的每条语句
30秒到达战场
相关分类