using System;
using System.Threading; //多线程调试: 2013.10.08
namespace ThreadExample
{
class App
{
public struct Data
{
public string Message;
} //将消息写入控制台
static void ThreadMainWithParameter(object o)
{
Data d = (Data)o;
Console.WriteLine("Running in a thread , receive {0}.",
d.Message);
} public static void Main()
{
var t1 = new Thread(() => Console.WriteLine("Running in a thread, id:{0}",
Thread.CurrentThread.ManagedThreadId));
t1.Start();
Console.WriteLine("This is the main thread, id:{0}",
Thread.CurrentThread.ManagedThreadId); var d = new Data { Message = "Info"};
var t2 = new Thread(ThreadMainWithParameter); //传递变量d
t2.Start(d);
} static void ThreadMain()
{
for (int i = ; i < ;i++ )
{
Console.WriteLine("Running in a thread {0}.",i);
}
}
}
}

输出结果:

C# 多线程传参的更多相关文章

  1. 3.多线程传参,以及tuple数组

    #include <Windows.h> #include <thread> #include <iostream> #include <tuple> ...

  2. C# 多线程传参 三种实例

    //using Thread to download files //1111111111111111 foreach (var str in listDownloadPdf) { //string ...

  3. Windows10 VS2017 C++多线程传参和等待线程结束

    #include "pch.h" #include <iostream> #include <windows.h> using namespace std; ...

  4. C# 多线程编程,传参,接受返回值

    C# 多线程编程,传参,接受返回值 今天将多线程的知识有回顾了下,总结了几点: 新建一个线程(无参数,无返回值) Thread th = new Thread(new ThreadStart(Prin ...

  5. ruby中的多线程和函数的关键字传参

    1.实现ruby中的多线程 # def test1 # n = 1 # if n > 10 # puts "test1结束" # else # while true # sl ...

  6. python 线程创建和传参(28)

    在以前的文章中虽然我们没有介绍过线程这个概念,但是实际上前面所有代码都是线程,只不过是单线程,代码由上而下依次执行或者进入main函数执行,这样的单线程也称为主线程. 有了单线程的话,什么又是多线程? ...

  7. Oracle 用Drapper进行like模糊传参查询需要在参数值前后带%符合

    Oracle 用Drapper进行like模糊传参查询需要在参数值前后带%符合   string sqlstr="select * from tblname where name like ...

  8. Angular页面传参的四种方法

    1. 基于ui-router的页面跳转传参 (1)在Angular的app.js中用ui-route定义路由,比如有两个页面, 一个页面(producers.html)放置了多个producers,点 ...

  9. 使用java传参调用exe并且获取程序进度和返回结果的一种方法

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 在某个项目中需要考虑使用java后台调用由C#编写的切图程序( ...

随机推荐

  1. svn 中 版本回退

    譬如有个文件,有十个版本,假定版本号是1,2,3,4,5,6,7,8,9,10. Revert to this revision: 如果在版本6这里点击“Revert to this revision ...

  2. linux命令(9)设定固定ip

    一.使用命令设置ubuntu的ip地址 1.修改配置文件blacklist.conf禁用IPV6: sudo vi /etc/modprobe.d/blacklist.conf 2.在文档最后添加 b ...

  3. 给Mac下的iTerm2增加配色

    iterm2就不说了,Mac下非常好用的终端,这里就先谈谈如何给其增加配色,效果如下图 可以来这下载theme : http://iterm2colorschemes.com/ 1.先编辑你的prof ...

  4. ylbtech-LanguageSamples-Yield

    ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-Yield 1.A,示例(Sample) 返回顶部 “Yield”示例 本示例演示如何创 ...

  5. Build常见错误

    1.ant 解决com.sun.tools.javac.Main is not on the classpath的问题 在ant打包时报错: 解决com.sun.tools.javac.Main is ...

  6. map遍历测试结果

    结论:一般情况下推荐使用enterSet的for循环(即以下的方法2),如果只是取key值可以使用keySet性能会更好. 因为keySet只取key,enterSet即取了key又取了value. ...

  7. JavaScript【面向对象】-静态方法-私有方法-公有方法-特权方法

    JavaScript面向对象是近年来比较火的一个概念了,由于小弟才疏学浅,虽然做过不少的web项目,看了网上很多深奥的资料和教程,还是对他们深奥 的理论一知半解,前段时间看了点书,总算有了自己的理解, ...

  8. [Flex] PopUpButton系列 —— 设置弹出菜单与主按钮之间的间隔

    <?xml version="1.0" encoding="utf-8"?><!--设置弹出菜单与主按钮之间的间隔 PopUpButtonPo ...

  9. Kinect测量人体身高的程序

    对着书上敲得,从中体会kinect骨骼识别与深度识别的原理.大体原理是懂了,但有些细节还没有完全弄明白. using System; using System.Collections.Generic; ...

  10. Inno Setup安装、卸载时判断是否程序正在运行

    var ErrorCode: Integer; IsRunning: Integer; // 安装时判断客户端是否正在运行 function InitializeSetup(): Boolean; b ...