delegate void StringParameterDelegate(int count); private void button2_Click_1(object sender, EventArgs e) { Thread workThread = new Thread(new ThreadStart(Counting)); workThread.IsBackground = true; workThread.Start(); //compu(); //workThread.Abort(); } private void Counting() { for (int i = 0; i < 10000000; i++) { UpdateLabelCount(i); Thread.Sleep(100); } } private void UpdateLabelCount(int count) { if (InvokeRequired) { // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new StringParameterDelegate(UpdateLabelCount), new object[] { count }); return; } label1.Text = count.ToString(); }
private void button1_Click(object sender, EventArgs e) { Thread workThread = new Thread(new ThreadStart(Counting)); workThread.IsBackground = true; workThread.Start(); } delegate void StringParameterDelegate(int count); delegate void StringParameterDelegate2(int count); private void Counting() { for (int i = 0; i < 10000000; i++) { UpdateLabelCount(i); Thread.Sleep(100); } } private void UpdateLabelCount(int count) { if (InvokeRequired) { // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new StringParameterDelegate(UpdateLabelCount), new object[] { count }); return; } label1.Text = count.ToString(); } private void Counting2() { for (int i = 0; i < 10000000; i++) { UpdateLabelCount2(i); Thread.Sleep(100); } } private void UpdateLabelCount2(int count) { if (InvokeRequired) { // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new StringParameterDelegate2(UpdateLabelCount2), new object[] { count }); return; } label2.Text = count.ToString(); } private void button2_Click(object sender, EventArgs e) { Thread workThread = new Thread(new ThreadStart(Counting2)); workThread.IsBackground = true; workThread.Start(); } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง