zoukankan      html  css  js  c++  java
  • C#之参数线程

    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.CheckForIllegalCrossThreadCalls = false;
            }
    
            private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                
            }
        }
    

      

    数组
    
    
    
    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)
            {
                
            }
        }
    

      

    集合
    
    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.CheckForIllegalCrossThreadCalls = false;
            }
    
            private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                
            }
        }
    

      

  • 相关阅读:
    [NOIP2013] 提高组 洛谷P1979 华容道
    Vijos P1404 遭遇战
    CodeVS 1506 传话
    P1546 最短网络 Agri-Net
    HDU 4747 Mex
    POJ1020 Anniversary Cake
    【数据结构】平衡二叉树
    【数据结构】二叉排序树
    【数据结构】二叉树
    概念源于生活
  • 原文地址:https://www.cnblogs.com/mengluo/p/5579712.html
Copyright © 2011-2022 走看看