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;
查看全文
相关阅读:
iOS 9之适配ATS(转载)
ios8 tableView设置滑动删除时 显示多个按钮
PHP IDE phpstorm 快捷键
ld: warning: directory not found for option 去掉警告的方法
iOS 评论APP撰写评论
集成IOS 环信SDK
iOS Xcode7免证书真机调试
iOS定时器
配置安装CocoPods后进行 项目基本配置
事务的概念
原文地址:https://www.cnblogs.com/aaa6818162/p/1535736.html
最新文章
使用yii2开发基础配置
简单分页
小程序callback not a function
桌面图标编程其他的图标解决
小程序配置https
网易云音乐获取播放链接
数据库报错Unknown column 'oKj5V4xN' in 'where clause'
php输出报错Message: Array to string conversion
php中使用curl发送请求和图片压缩
ci中post方式提交数据和接受数据
热门文章
JavaFX可视化拖拽工具
固态硬盘测速工具
数据库工具
数据库建模工具
屏幕录像工具
如何在Notepad++中格式化json?
Java代码反编译工具
Java代码反编译工具
如何通过JFR对Java应用程序进行性能记录?
JavaScript 页面模板引擎
Copyright © 2011-2022 走看看