using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace MultiThreading
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private bool check = true;
public void race1()
{
for (int i = 0; i <=5000; i++)
{
if(check)
{
textBox1.Text = i.ToString();
}
else
break;
}
check = false;
}
public void race2()
{
for (int i = 0; i <=5000; i++)
{
if (check)
{
textBox2.Text = i.ToString();
}
else
break;
}
check = false;
}
private void button1_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
th1.Name = "thread1";
Thread th2 = new Thread(race2);
th2.Name = "thread2";
th1.Start();
th2.Start();
}
private void btnsuspend_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Suspend();
th2.Suspend();
}
private void btnresume_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Resume();
th2.Resume();
}
private void btnabort_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Abort();
th2.Abort();
} private void btnsuspend_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Suspend();
th2.Suspend();
}
private void btnresume_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Resume();
th2.Resume();
}
private void btnabort_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Abort();
th2.Abort();
} private void btnsuspend_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Suspend();
th2.Suspend();
}
private void btnresume_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Resume();
th2.Resume();
}
private void btnabort_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Abort();
th2.Abort();
}
{
private void Form1_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace MultiThreading
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private bool check = true;
public void race1()
{
for (int i = 0; i <=5000; i++)
{
if(check)
{
textBox1.Text = i.ToString();
}
else
break;
}
check = false;
}
public void race2()
{
for (int i = 0; i <=5000; i++)
{
if (check)
{
textBox2.Text = i.ToString();
}
else
break;
}
check = false;
}
private void button1_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
th1.Name = "thread1";
Thread th2 = new Thread(race2);
th2.Name = "thread2";
th1.Start();
th2.Start();
}
private void btnsuspend_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Suspend();
th2.Suspend();
}
private void btnresume_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Resume();
th2.Resume();
}
private void btnabort_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Abort();
th2.Abort();
} private void btnsuspend_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Suspend();
th2.Suspend();
}
private void btnresume_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Resume();
th2.Resume();
}
private void btnabort_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Abort();
th2.Abort();
} private void btnsuspend_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Suspend();
th2.Suspend();
}
private void btnresume_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Resume();
th2.Resume();
}
private void btnabort_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(race1);
Thread th2 = new Thread(race2);
th1.Abort();
th2.Abort();
}
{
private void Form1_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
}
}
}
No comments:
Post a Comment