大家帮我看看这个程序为甚么不能执行呢?
ldxab 2010-04-07 06:21:20 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
int i=0;
public Form1()
{
InitializeComponent();
}
public void runbar()
{
while(true)
{
progressbar.Value += 1;
}
}
private void button1_Click(object sender, EventArgs e)
{
new System.Threading.Thread(new System.Threading.ThreadStart(runbar)).Start();//创建一个新的线程并启动
while (true)
{ Thread.Sleep(1000); }
}
private void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
}
}
}
我的想法是 progressbar.Value 不段增加,但下面这段代码只能执行一次,我也不知为什么,请高手看看
public void runbar()
{
while(true)
{
progressbar.Value += 1;
}
}