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();
        }

 

posted @ 2020-03-22 19:09  帝雪寒天  阅读(181)  评论(0编辑  收藏  举报