• 进程、多线程


    进程

      整个公司 - 一个进程 - 一个程序

      Process.Start("");

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;//1引用命名空间
    
    namespace WindowsFormsApplication5
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //Process.Start("calc");//calc计算器括号内内要打卡的程序名字符串型的
                //Process.Start("Chrome","http://www.baidu.com");//用谷歌的浏览器打开
                //Process.Start("http://www.baidu.com");//用用户电脑默认的浏览器打开
                Process.Start(textBox1.Text);//4、打开
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                //浏览并打开应用程序
                //1、在from1中一个浏览按钮一个打开按钮一个TextBox用于接收浏览的路径和一个OpenFileDialog
                openFileDialog1.Filter = "应用程序|*.exe";//3、只能看应用程序
                DialogResult dr = openFileDialog1.ShowDialog();
                if (dr == DialogResult.OK)//2、如果点的是确定将选中的文件在textBox1.Text显示出来
                {
                    textBox1.Text = openFileDialog1.FileName;
                }
            }
        }
    }

    线程

      默认程序中只有一个线程 - 公司老板

      同一时间只能做一件事 主线程 - 老板

      线程 - 公司中的员工,临时工

    1、启用线程

      引用命名空间:using System.Threading;

      Thread th = new Thread(Test1);

      th.Start();

    2、主线程/进程关闭后,子线程不会立刻退出

      默认线程都是前台线程

      把前台线程变为后台线程

        th.IsBackground = true;

    3、默认是不允许跨线程访问

      关闭监控

        Control.CheckForIllegalCrossThreadCalls = false;

    4、只开启一个线程

         让按钮不可用

        中间变量判断

    5、中止线程

      th.Abort();

  • 相关阅读:
    功能:Java注解的介绍和反射使用
    功能:@Vaild注解使用及扩展
    转载:微信小程序view布局
    功能:Java8新特性steam流
    功能:Linux运行jar包Shell脚本
    转载:Windows使用tail -f 监控文件
    转载:java.math.BigDecimal 比较大小
    问题:跨域及解决方案
    基于 @SelectProvider 注解实现无侵入的通用Dao
    SpringBoot中的异步操作与线程池
  • 原文地址:https://www.cnblogs.com/skyhorseyk/p/7209953.html
Copyright © 2020-2023  润新知