ji ming u
چهارشنبه 13 آبان 1394, 11:51 صبح
سلام
دوستان من تازه یادگیری مبحث thread را اغاز کردم
تو یه فایل تصویری مثالی را انجام داد ولی من عین اون مثال را نوشتم ولی exception رخ میده
مشکل از کجاست
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
static Thread t1;
static ThreadStart ts1;
int i = 0;
public void fun1()
{
while(true)
{
label2.Text = i.ToString();
i++;
}
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ts1 = new ThreadStart(fun1);
t1 = new Thread(ts1);
t1.Start();
}
}
}
دوستان من تازه یادگیری مبحث thread را اغاز کردم
تو یه فایل تصویری مثالی را انجام داد ولی من عین اون مثال را نوشتم ولی exception رخ میده
مشکل از کجاست
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
static Thread t1;
static ThreadStart ts1;
int i = 0;
public void fun1()
{
while(true)
{
label2.Text = i.ToString();
i++;
}
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ts1 = new ThreadStart(fun1);
t1 = new Thread(ts1);
t1.Start();
}
}
}