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;
查看全文
相关阅读:
拓端tecdat|R语言具有Student-t分布改进的GARCH(1,1)模型的贝叶斯估计
拓端tecdat|R语言有极值(EVT)依赖结构的马尔可夫链(MC)对洪水极值分析
拓端tecdat|R语言Lee-Carter模型对年死亡率建模预测预期寿命
拓端tecdat|R语言中的模拟过程和离散化:泊松过程和维纳过程
接口自动化文章收藏
【转】python中获得当前目录和上级目录
面试题
【转】python字符串/元组/列表/字典互转
session关联接口
r.json()
原文地址:https://www.cnblogs.com/tommyli/p/922589.html
最新文章
python入门005
python入门006
Python入门002
CF721D Maxim and Array(贪心)
CF8C Looking for Order(状压DP)
CF940E Cashback(DP)
CF20B Equation(一元二次方程求解)
CF494B Obsessive String(KMP+DP)
CF1256F Equalizing Two Strings(冒泡排序、思维)
CF526C Om Nom and Candies(思维)
热门文章
CF749D Leaving Auction(二分)
CF1009E Intercity Traveling(数学、找规律)
CF1405D Tree Tag(树的直径+博弈,惨痛的失利)
会计年度变式分配给公司
会计期间
分配公司字段状态变式
给信贷控制区分配公司代码
给公司代码分配公司
查看成本中心报表
显示附加信息
Copyright © 2011-2022 走看看