http://stephencleary.com/projects/

    /// <summary>
///
/// </summary>
public partial class Form2 : Form
{ //[ComVisible(false)]
//public delegate void ParameterizedThreadStart(object objfield); /// <summary>
///
/// </summary>
public Form2()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form2_Load(object sender, EventArgs e)
{
MyDu du = new MyDu(); Control.CheckForIllegalCrossThreadCalls = false;
Thread t1 = new Thread(new ThreadStart(TestMethod));
Thread t2 = new Thread(new ParameterizedThreadStart(TestMethod));
//Thread t3 = new Thread(new ThreadStart(du.setData));
ThreadPool.QueueUserWorkItem(new WaitCallback(TaskProc1), new Person { Id = 1, Name = "测试", Count =100 }); du.BegID = 100;
du.EndID = 20000;
du.Le1 = this.label3;
du.Le2 = this.label4;
Thread t3 = new Thread(new ThreadStart(du.Run)); t1.IsBackground = true;
t2.IsBackground = true;
t3.IsBackground = true;
t1.Start();
t2.Start("hello");
t3.Start();
}
/// <summary>
///
/// </summary>
/// <param name="x"></param>
public void TaskProc1(object x) //执行的任务
{
Person person = x as Person; }
//
private delegate void InvokeCallback(string msg);
//
private delegate void SetLabelDelegate(string value);
/// <summary>
///
/// </summary>
void TestMethod()
{ //InvokeCallbackmsgCallback = new InvokeCallback(m_comm_MessageEvent);
string v = "geovind du 1";
this.label1.Text = v;
//if (this.InvokeRequired)
//{
// SetLabelDelegate d = new SetLabelDelegate(TestMethod);
// this.Invoke(d, new object[] { v});
//}
//else
//{
// this.label1.Text = v;
//}
} void TestMethod(object data)
{
if (this.InvokeRequired)
{
SetLabelDelegate d = new SetLabelDelegate(TestMethod);
this.Invoke(d, new object[] { data });
}
else
{
string datastr = data as string;
this.label2.Text = datastr;
}
} } public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public int Count { get; set; } }
/// <summary>
///
/// </summary>
class MyDu
{ private int begID; public int BegID { set{this.begID=value;} } private int endID; public int EndID { set{this.endID=value;} } private Label le1; public Label Le1
{
set { this.le1 = value; }
} private Label le2; public Label Le2
{
set { this.le2 = value; }
}
/// <summary>
///
/// </summary>
public void Run()
{ method(begID, endID, le1, le2); }
/// <summary>
///
/// </summary>
/// <param name="begin"></param>
/// <param name="end"></param>
private void method(int begin,int end,Label labe,Label labe2)
{
labe.Text = begin.ToString();
labe2.Text = end.ToString();
} }
}

  

Concurrency in csharp (Asynchronous, Parallel, and Multithreaded Programming)的更多相关文章

  1. What is the difference between concurrency, parallelism and asynchronous methods?

    Ref: http://stackoverflow.com/questions/4844637/what-is-the-difference-between-concurrency-paralleli ...

  2. (转) [it-ebooks]电子书列表

    [it-ebooks]电子书列表   [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...

  3. Introduction to Multi-Threaded, Multi-Core and Parallel Programming concepts

    https://katyscode.wordpress.com/2013/05/17/introduction-to-multi-threaded-multi-core-and-parallel-pr ...

  4. PatentTips - Heterogeneous Parallel Primitives Programming Model

    BACKGROUND 1. Field of the Invention The present invention relates generally to a programming model ...

  5. A Pattern Language for Parallel Application Programming

    A Pattern Language for Parallel Application Programming Berna L. Massingill, Timothy G. Mattson, Bev ...

  6. Java 8 Concurrency Tutorial--转

    Threads and Executors Welcome to the first part of my Java 8 Concurrency tutorial. This guide teache ...

  7. 【转】Multithreaded Python Tutorial with the “Threadworms” Demo

    The code for this tutorial can be downloaded here: threadworms.py or from GitHub. This code works wi ...

  8. Introduction to Parallel Computing

    Copied From:https://computing.llnl.gov/tutorials/parallel_comp/ Author: Blaise Barney, Lawrence Live ...

  9. 并行parallel和并发concurrent的区别

    http://stackoverflow.com/questions/1050222/concurrency-vs-parallelism-what-is-the-difference Concurr ...

随机推荐

  1. Python黑帽编程2.1 Python编程哲学

    Python黑帽编程2.1  Python编程哲学 本节的内容有些趣味性,涉及到很多人为什么会选择Python,为什么会喜欢这门语言.我带大家膜拜下Python作者的Python之禅,然后再来了解下P ...

  2. TODO:Ubuntu下安装Node

    TODO:Ubuntu下安装Node Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高 ...

  3. MySQL_01之MySQL数据库基础

    1.通过SQL(结构化查询语言)操作数据库: DDL:数据定义语言,创建库,创建表,选择: DML:数据操作语言,完成数据增删改: DQL:数据查询语言,完成数据查询: DCL:数据控制语言,授权.回 ...

  4. 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

  5. 单页面实现之hash

    至学了angularJs后,发现这个单页面应用不知道在没有angularJs的情况下怎么实现. 所以就此对这个思考与资料并行,终于知道这个的实现基本原理. 首先angularJs的实现是hash值的变 ...

  6. QUOTED_IDENTIFIER 选项对 index 的影响

    在修改或创建Index时,有时会收到一些Error Message,指明Set options设置错误,最常见的选项是:SET QUOTED_IDENTIFIER 选项 当创建或修改的index包含c ...

  7. 【Win 10应用开发】认识一下UAP项目

    Windows 10 SDK预览版需要10030以上版本号的Win 10预览版系统才能使用.之前我安装的9926的系统,然后安装VS 2015 CTP 6,再装Win 10 SDK,但是在新建项目后, ...

  8. jQuery 2.0.3 源码分析 回调对象 - Callbacks

    源码API:http://api.jquery.com/jQuery.Callbacks/ jQuery.Callbacks()是在版本1.7中新加入的.它是一个多用途的回调函数列表对象,提供了一种强 ...

  9. 轻量级前端MVVM框架avalon - 执行流程1

    基本上确定了avalon的几个重要元素的关系: M,即model,一个普通的JS对象,可能是后台传过来的,也可能是直接从VM中拿到,即VM.$json.有关的这个$json的名字还在商讨 V,即Vie ...

  10. WPF自定义控件与样式(2)-自定义按钮FButton

    一.前言.效果图 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 还是先看看效果 ...