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黑帽编程 3.3 MAC洪水攻击

    Python灰帽编程 3.3 MAC洪水 传统的交换机(我只对我目前使用的交互机做过测试,按照常识只能这样表述)在数据转发过程中依靠对CAM表的查询来确定正确的转发接口,一旦在查询过程中无法找到相关目 ...

  2. OOAD利器之UML基础

    UML:Unified Modeling Language,即统一建模语言,简单地说就是一种有特殊用处的语言.本文是我初步学习UML的学习笔记,对于我们菜鸟码农来说,让我们做设计的可能性不大,但至少能 ...

  3. C语言 · 回文数

    问题描述 1221是一个非常特殊的数,它从左边读和从右边读是一样的,编程求所有这样的四位十进制数. 输出格式 按从小到大的顺序输出满足条件的四位十进制数.   方案一: int main(){ int ...

  4. 每天一个linux命令(48):watch命令

    watch是一个非常实用的命令,基本所有的Linux发行版都带有这个小工具,如同名字一样,watch可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行.在Linux下,watch是周期性的执行下个 ...

  5. [大数据之Spark]——Transformations转换入门经典实例

    Spark相比于Mapreduce的一大优势就是提供了很多的方法,可以直接使用:另一个优势就是执行速度快,这要得益于DAG的调度,想要理解这个调度规则,还要理解函数之间的依赖关系. 本篇就着重描述下S ...

  6. sublime3 插件

    Sublime Text 3能用支持的插件推荐 从二月份用测试版本build 3012开始用sublime text 3,虽然很多插件在sublime text 3不工作了,因为sublime tex ...

  7. Atitit webservice的发现机制 discover机制

    Atitit webservice的发现机制 discover机制 1.1. Ws disconvert 的组播地址和端口就是37021 1.2. Ws disconvert的发现机制建立在udp组播 ...

  8. kettle资源库配置

    资源库的作用:资源库是用来保存操作步骤和相关的日志,转换,JOB 等信息.用户通过图形界面创建的的转换任务可以保存在资源库中.资源库可以是各种常见的数据库,用户通过用户名/ 密码来访问资源库中的资源, ...

  9. Dynatree使用

    最近用到了Dynatree的树形结构,记录一下它的用法. 需求: 1.jquery.js 2.jquery-ui.custom.js 3.jquery.cookie.js 下载dynatree,放到资 ...

  10. ThinkPHP3.2设置404跳转页面

    在ThinkPHP3.2版本中当我们访问不存在的页面时会出现非常不友好错误提示页面,类如下图: 解决办法: 1.在ThinkPHP3.2详细的介绍了该框架下的ThinkPHP惯例配置文件convent ...