关于窗体与多线程的问题
在窗体中添加两个Lable控件和一个Button控件。单击Button控件在两个Lable控件中显示计算结果。代码是:using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace LXK
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Thread th1, th2;
double x1, x2;
private void button1_Click(object sender, EventArgs e)
{
th1 = new Thread(new ThreadStart(fangfa1));
th2 = new Thread(new ThreadStart(fangfa2));
th1.Start();
th2.Start();
}
private void fangfa1()
{
for (int i = 0; i < 50; i++)
{
x1 = i * 2;
label1.Text += x1.ToString();
}
}
private void fangfa2()
{
for (int i = 0; i < 50; i++)
{
x2 = i + 2;
label2.Text += x2.ToString();
}
}
private void Form3_Load(object sender, EventArgs e)
{
button1.Text = "OK";
label1.BorderStyle = BorderStyle.Fixed3D;
label2.BorderStyle = BorderStyle.FixedSingle;
}
}
}
运行提示错误,请帮忙解决下。谢谢。