首页 技术 正文
技术 2022年11月14日
0 收藏 891 点赞 3,734 浏览 2216 个字

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();
} }
}

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,136
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,300