C#之进程、线程

进程Process

通过进程打开一个应用程序或文件

调用命名空间:

using System.Diagnostics;

Process.Start("calc");

线程类:

using System.Threading;
        Thread thread1;
        private void button1_Click(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

            thread1 = new Thread(Thread1_Method);
            thread1.IsBackground = true;
            thread1.Start();

        }

        private void Thread1_Method()
        {
            int i = 0;
            while (true)
            {
                textBox1.Text = i.ToString();
                i++; 
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            thread1.Abort();
        }

猜你喜欢

转载自www.cnblogs.com/LynnXue/p/12547716.html