System.Threading.Thread的使用及传递参数等总结
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
//线程启动One()
Thread t = new Thread(() => One());
t.Start();
//线程启动One(object p) 方法一(传递参数)
Thread tt = new Thread(() => One("mang"));
tt.Start();
//线程启动Two(object p) 方法二(传递参数)
Thread ttt = new Thread(new ParameterizedThreadStart(Two));
ttt.Start("mangmang");
Console.ReadLine();
//构造函数
//new Thread(ThreadStart start) 初始化Thread类的新实例
//start 类型:System.Threading.ThreadStart
// ThreadStart委托,它表示此线程开始执行时要调用的方法。
}
static void One()
{
Console.WriteLine("One");
}
static void One(object p)
{
Console.WriteLine("One's parameter is " + p.ToString());
}
static void Two(object p)
{
Console.WriteLine("Two's parameter is " + p.ToString());
}
}
}
System.Threading.Thread的使用及传递参数等总结的更多相关文章
- C#中的线程四(System.Threading.Thread)
C#中的线程四(System.Threading.Thread) 1.最简单的多线程调用 System.Threading.Thread类构造方法接受一个ThreadStart委托,改委托不带参数,无 ...
- MVC4 + EF + System.Threading.Thread 出现的问题记录
项目要求是页面监测到后台数据库用户数据(Users)变化,前台做出相应的响应和操作. 一.参考很多资料,大概有几种方式: 参考资料地址:http://www.cnblogs.com/hoojo/p/l ...
- 异常System.Threading.Thread.AbortInternal
异常信息: System.Threading.ThreadAbortException: 正在中止线程. 在 System.Threading.Thread.AbortInternal() 在 Sys ...
- c# System.Threading.Thread
using System; using System.Threading; // Simple threading scenario: Start a static method running // ...
- .Net 指定时间段内定时执行的Windows服务(System.Threading.Thread)
创建一个Windows服务项目:解决方案(右击)——> 添加 ——> 新建项目——>项目类型选择Windows——>模板选择Windows服务 ,如图: 编写Windows服务 ...
- 【.Net 学习系列】-- .Net 指定时间段内定时执行的Windows服务(System.Threading.Thread)
创建一个Windows服务项目:解决方案(右击)——> 添加 ——> 新建项目——>项目类型选择Windows——>模板选择Windows服务 ,如图: 编写Windows服务 ...
- 【异常记录(九)】 System.Threading.ThreadAbortException: 正在中止线程
报错如下: System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.Ab ...
- System.Threading
线程:定义为可执行应用程序中的基本执行单元. 应用程序域:一个应用程序内可能有多个线程. 上下文:一个线程可以移动到一个特定的上下文的实体 导入命名空间: //得到正在执行这个方法的线程 Thread ...
- using System.Threading;
/// <summary> /// 执行动作:耗时而已 /// </summary> private void TestThread(string threadName) { ...
随机推荐
- QuickReport FastReport
一.QuickReport1.安装Component->Install packages->X:/Program Files/Borland/Delphi7/Bin/dclqrt70.bp ...
- R语言的学习笔记 (持续更新.....)
1. DATE 处理 1.1 日期格式一个是as.Date(XXX) 和strptime(XXX),前者为Date格式,后者为POSIXlt格式 1.2 用法:as.Date(XXX,"%Y ...
- Mybatis异常_04_mapper.xml中不能使用小于号<、大于号>
一.解决方法: 1.< 2.<![CDATA[ < ]]> 将小于号替换为上述代码即可. 二.参考资料 1.mybatis配置中sql莫名其妙报错,多半是条件中小于符号捣的鬼
- php 实现分享到QQ空间 新浪微博
//分享到新浪微博 $('#blog').click(function(){ window.sharetitle = '<%$info.title%>';//标题 window.share ...
- 大白话AOP
工作一年多后, 第二次看了韩顺平老师讲的AOP (11年的Spring 教学视频) AOP还是比较艰涩的东西. 从刚开始 碰Java项目去找书看开始, 到学了拦截器知道AOP就是处理事务, 日志, 安 ...
- Convolutional Neural Networks for Visual Recognition 1
Introduction 这是斯坦福计算机视觉大牛李菲菲最新开设的一门关于deep learning在计算机视觉领域的相关应用的课程.这个课程重点介绍了deep learning里的一种比较流行的模型 ...
- 【leetcode刷题笔记】Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...
- P1030 求先序排列
题目描述 给出一棵二叉树的中序与后序排列.求出它的先序排列.(约定树结点用不同的大写字母表示,长度<=8). 输入输出格式 输入格式: 2行,均为大写字母组成的字符串,表示一棵二叉树的中序与后序 ...
- python中http的一些编码转换
http的数据需要2种编码解码. 1. url中的特殊字符转换, 比如",', :,//等 python3中通过urllib.parse.quote(..)和urllib.parse.unq ...
- jQuery做出手风琴效果
今天学到JQuery中的遍历-siblings,便手痒做了个手风琴的动态效果,有一点收获,分享给大家.mouseout的时候一定要记得opacity必须设置,不然li的opacity会保持mousem ...