编程语言
首页 > 编程语言> > 自学C#多线程Thread的应用

自学C#多线程Thread的应用

作者:互联网

WMI是英文Windows Management Instrumentation的简写,它的功能主要是:访问本地主机的一些信息和服务,可以管理远程计算机(当然你必须要拥有足够的权限),比如重启,关机,关闭进程,创建进程等。

当然此文是适用于vbscript

微软官方的资料:

实例如下:

用WMI,先工程-引用 Microsoft WMI Scripting V1.1 Library

获取显卡/声卡/内存/操作系统的信息

分享了C#多线程Thread使用的示例代码基本使用示例:

using System;

using System.Threading;    namespace month_9_10._1009 {     class Run5     {         /* 测试线程的调用过程          * 主线程输出world,子线程输出hello          */         public static void showHello()         {             for(int i = 0; i < 100; i++)             {                 Console.WriteLine($"Hello\t#{Thread.CurrentThread.Name}");             }         }         public static void Main(string[] args)         {             Thread.CurrentThread.Name = "Main Thread!";             var childThreadRef = new ThreadStart(showHello);             Console.WriteLine("This is Main process!!!");             var childThread = new Thread(childThreadRef);             childThread.Name = "Child Thread!";             childThread.Start();             for (int i = 0; i < 100; i++)             {                 Console.WriteLine($"World!\t#{Thread.CurrentThread.Name}");             }         }     } } 线程生命周期状态图,C#线程优先级。

硬件类
Computer System Hardware Classes
he Cooling Devices subcategory groups classes that represent instrumentable fans, temperature probes, and refrigeration devices.

Class Description
Win32_Fan Represents the properties of a fan device in the computer system.
Win32_HeatPipe Represents the properties of a heat pipe cooling device.
Win32_Refrigeration Represents the properties of a refrigeration device.
Win32_TemperatureProbe Represents the properties of a temperature sensor (electronic thermometer).

Input Device Classes

The Input Devices subcategory groups classes that represent keyboards and pointing devices.

Class Description
Win32_Keyboard Represents a keyboard installed on a Windows system.

实例三:线程同步(售票模拟)

using System; using System.Drawing; using System.Threading; using System.Windows.Forms; namespace RollMove {     public partial class Form1 : Form     {         Thread th1 = null;         public Form1()         {             InitializeComponent();                       }         private void Form1_Load(object sender, EventArgs e)         {             int _sx = 40;             int _ex = 280;             int _top = 70;             th1 = new Thread(() => {                 while (true)                 {                     if (_sx <= _ex)                     {                         _ex = 280;                         label1.Location = new Point(_sx, _top);                         Thread.Sleep(20);                         _sx += 5;                     }                     else                     {                         _ex = 40;                         label1.Location = new Point(_sx, _top);                         Thread.Sleep(20);                         _sx -= 5;                     }                 }             });             th1.Start();         }            private void Form1_FormClosed(object sender, FormClosedEventArgs e)         {             if (th1!=null)             {                 th1.Abort();             }         }     } }

可以找到,其中也还有部分示例代码

简单Win_32类表

Win32 Classes
Microsoft&reg; Windows&reg; classes give you the means to manipulate a variety of objects. The following table identifies the categories of Windows classes.

Category Description
Computer system hardware Classes that represent hardware related objects.
Operating system Classes that represent operating system related objects.
Installed applications Classes that represent software related objects.
WMI service management Classes used to manage WMI.
Performance counters Classes that represent formatted and raw performance data.

自学C#多线程Thread的应用

标签:represent,sx,Thread,C#,System,Classes,using,多线程
来源: https://www.cnblogs.com/thinkjing/p/15021876.html