Public Form1 () {InitializeComponent (); } Thread t; private void Button1_Click (object sender, EventArgs e) {int num = Int. Parse (This.textBox1.Text); int num2 = Int. Parse (This.textBox2.Text); Duo A = new duo (); A.NUM1 = num; a.num2 = num2; t = new Thread (test); T.isbackground = true; T.start (a); } private void Test (object num) {duo A = num as duo; int n = 0; while (n < 10000)//{//n++; This.textBox1.Text = N.tostring (); } int n = a.num1; int b = a.num2; This.label1.Text = Convert.ToString ((n + B) * B/2); private void Form1_Load (object sender, EventArgs e) {Control.checkforillegalcrossthread Calls = false; private void Form1_formclosing (object sender, FormClosingEventArgs e) {}}
Array public partial class Form1:form {public Form1 () {InitializeComponent (); } Thread t; private void Button1_Click (object sender, EventArgs e) {int num = Int. Parse (This.textBox1.Text); int num2 = Int. Parse (This.textBox2.Text); Int[] A = new int[] {num,num2}; t = new Thread (test); T.isbackground = true; T.start (a); } private void Test (object num) {int[] nums= (int[]) num; int n = 0; while (n < 10000)//{//n++; This.textBox1.Text = N.tostring (); } int n = nums[0]; int b = nums[1]; This.label1.Text = Convert.ToString ((n + B) * B/2); private void Form1_Load (object sender, EventArgs e) {Control.checkForillegalcrossthreadcalls = false; private void Form1_formclosing (object sender, FormClosingEventArgs e) {}}
Set public partial class Form1:form {list<int> add = new list<int> (); Public Form1 () {InitializeComponent (); } Thread t; private void Button1_Click (object sender, EventArgs e) {Add. Clear (); int num = Int. Parse (This.textBox1.Text); int num2 = Int. Parse (This.textBox2.Text); Add. ADD (num); Add. ADD (NUM2); t = new Thread (test); T.isbackground = true; T.start (add); } private void Test (object num) {//int nums= (int) num; List<int> nums = (list<int>) num; int n = 0; while (n < 10000)//{//n++; This.textBox1.Text = N.tostring (); } int n = nums[0]; int b = nums[1]; This.label1. Text = Convert.ToString ((n + B) * B/2); private void Form1_Load (object sender, EventArgs e) {Control.checkforillegalcrossthread Calls = false; private void Form1_formclosing (object sender, FormClosingEventArgs e) {}}
C # parameter thread