C#——线程基础
来源:互联网 发布:无法触碰影评 知乎 编辑:程序博客网 时间:2024/06/05 04:40
时间:2016.10.31
介绍线程相关的基础基础部分
1. 基础知识
C#中的Thread类
public sealed class Thread : CriticalFinalizerObject, _Thread{ // 四个基础构造函数 public Thread( ThreadStart start ); public Thread( ParameterizedThreadStart start ); public Thread( ThreadStart start, int maxStacksize ); public Thread( ParameterizedThreadStart start, int maxStackSize ); //...}
其中,线程函数可以是两种类型
[ComVisible(true)] public delegate void ThreadStart(); [ComVisible(false)] public delegate void ParameterizedThreadStart(object obj);
2. 最简单的示例
在命令控制台项目中,创建一个最简单的线程并启动线程
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Threading;namespace ThreadTest{ static class ThreadTest { static void main(string[] args) { new Thread( ThreadProc ).Start(); } static private void ThreadProc() { int count = 0; while( true ) { Console.WriteLine( " current count is: {0}", count ); count++; Thread.Sleep( 1000 ); } } } }
【返回】
C#分类目录
0 0
- C#——线程基础
- C语言-线程基础
- Java基础—线程
- 线程基础—线程的创建
- 线程基础—线程的同步
- 【Windows】线程漫谈——线程基础&线程栈
- java基础—— 线程
- Java基础——线程
- java基础——线程
- 【java基础】——线程
- 线程学习——基础
- Linux——线程基础
- java基础学习—线程
- java基础—线程入门
- 【C语言】【unix c】线程的基础
- C#——基础
- C/C++——线程池:目录
- C/C++——线程池:CThreadPoolManager
- 大数据开发利器:Hadoop(4)
- JS中在html中加载的顺序
- The VirtualBox kernel modules do not match this version of VirtualBox 解决 (linux update,nvidia失败)
- qt---cdb(Microsoft Console Debugger)调试
- 初用Intellij GUI Form
- C#——线程基础
- activity的四中启动模式
- 如何解决python2.7x 版本的安装出错问题
- 对象
- 经典算法题目:Cracking the coding interview 问题与解答
- week5 4-1 CheckBST[1]
- iOS rtf 和 ttf 字体导入技巧(iOS应用自定义字体)
- Rust语言教程(1) - 一门没有GC的语言
- WAMPServer下Apached的多站点配置