zoukankan
html css js c++ java
多线程,委托例子
多线程:
Type text here
class
ActiveDate
{
private
string
_CusID;
private
string
_Visitor;
private
int
_ShopNum;
private
int
_flag
=
0
;
public
int
Flag
{
get
{
return
_flag; }
set
{ _flag
=
value; }
}
public
string
CusID
{
get
{
return
_CusID; }
set
{ _CusID
=
value; }
}
public
string
Visitor
{
get
{
return
_Visitor; }
set
{ _Visitor
=
value; }
}
public
int
ShopNum
{
get
{
return
_ShopNum; }
set
{ _ShopNum
=
value; }
}
public
void
GetCustomerVisitor()
{
_Visitor
=
DAL.CRM.Common.Customer.GetCustomerVisitor(_CusID);
lock
(
this
)
{
_flag
++
;
}
}
public
void
GetCustomerShopNums()
{
_ShopNum
=
Convert.ToInt32(DAL.CRM.Common.Customer.GetCustomerShopNum(_CusID));
lock
(
this
)
{
_flag
++
;
}
}
}
Module.CRM.Customer.CustomerActiveDate date
=
new
Module.CRM.Customer.CustomerActiveDate();
ActiveDate ad
=
new
ActiveDate();
ad.CusID
=
customerID;
Thread tr1
=
new
Thread(
new
ThreadStart(ad.GetCustomerVisitor));
Thread tr2
=
new
Thread(
new
ThreadStart(ad.GetCustomerShopNums));
tr1.Start();
tr2.Start();
while
(
true
)
{
if
(ad.Flag
==
2
)
{
date.Visitor
=
ad.Visitor;
date.ShopNum
=
ad.ShopNum;
tr1.Abort();
tr2.Abort();
return
date;
}
}
委托:
delegate
string
myDelegate(String Name);
myDelegate d1
=
new
myDelegate(DAL.CRM.Common.Customer.GetCustomerVisitor);
myDelegate d2
=
new
myDelegate(DAL.CRM.Common.Customer.GetCustomerShopNum);
IAsyncResult i1
=
d1.BeginInvoke(customerID,
null
,
null
);
Module.CRM.Customer.CustomerActiveDate date
=
new
Module.CRM.Customer.CustomerActiveDate();
IAsyncResult i2
=
d2.BeginInvoke(customerID,
null
,
null
);
bool
_flag
=
false
;
while
(
!
_flag)
{
_flag
=
i1.IsCompleted
&&
i2.IsCompleted;
}
date.Visitor
=
d1.EndInvoke(i1);
date.ShopNum
=
Convert.ToInt32(d2.EndInvoke(i2));
return
date;
查看全文
相关阅读:
实现div 垂直居中
CSS 轮廓---outline属性
CSS 伪类 (Pseudo-classes)
HTML默认样式和浏览器默认样式
VHDL之concurrent之block
VHDL之concurrent之generate
VHDL之concurrent之when
VHDL之concurrent之operators
QS之force(2)
QS之force(1)
原文地址:https://www.cnblogs.com/tommyli/p/922589.html
最新文章
Attribute在.NET编程中的应用(三)
C#动态获取鼠标坐标
非确定性计算引擎转化为C#版本并重构
异步获取CMD命令行输出内容
C#去掉字符串头尾指定字符
C#实现中国身份证验证问题
列表操作2
列表操作1
while循环
初识Python
热门文章
web app 、native app、hybrid app比较
fiddler--配置火狐代理配置代理
【eclipse jar包】在编写java代码时,为方便编程,常常会引用别人已经实现的方法,通常会封装成jar包,我们在编写时,只需引入到Eclipse中即可。
聊聊自动化测试框架
关于Echarts
thinkphp实现文件上传
Ueditor 文本编辑器下载地址及用法
mvc思想简介
Wamp修改端口的方法
jQuery中的.height()、.innerHeight()和.outerHeight()
Copyright © 2011-2022 走看看