ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

自学C#多线程Thread的应用

2021-07-16 21:31:43  阅读:238  来源: 互联网

标签:represent sx Thread C# System Classes using 多线程


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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有