zoukankan      html  css  js  c++  java
  • c#线程创建

    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 WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            Thread th;
            private void button1_Click(object sender, EventArgs e)
            {
              th = new Thread(test);
                th.IsBackground = true;
                th.Start();
                    
            }
    
            private void test() 
            {
                int n = 100000;
                this.textBox1.Text = Convert.ToString((1 + n) * n / 2);
                  
                
               
                
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                Control.CheckForIllegalCrossThreadCalls = false;
            }
    
          
    
            private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
    
                if (th != null)
                {
                    th.Abort();
                }
            }
        }
    }
    

      

  • 相关阅读:
    第七章11
    第七章10
    第七章9
    第七章8
    第七章7
    第七章6
    第七章5
    第七章例7-13
    第七章例7-12
    第七章例7-11
  • 原文地址:https://www.cnblogs.com/mengluo/p/5576920.html
Copyright © 2011-2022 走看看