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;
查看全文
相关阅读:
售后返修管理软件流程设计图
Easyui datagrid加载数据时默认全选的问题
如何做好售后管理之售后返修品管理
您需要售后返修管理软件的N个理由
使用软件量化考核售后维修人员业绩?
如何使用NET Reactor为您的.Net(C#,VB.Net) 源代码加密!
VS.Net开发必备,让您的代码自动收缩,如何实现!
vs生成dll,却没有生成相应的lib
c++、webServices、gsoap、tinyxml、iconv
gsoap、c++。webservice的client。
原文地址:https://www.cnblogs.com/tommyli/p/922589.html
最新文章
协程,IO模式
常用模块
分页组件
django之ajax组件
session和cookie组件
django的admin
前端之bootstrap
jQuery绑定事件
前端之jQuery
css属性相关及盒子模型
热门文章
模块的循环导入问题
数据库引擎是什么?
PIC和PIE
C++11中的右值引用
【转】Linux Page Cache的工作原理
【转】Bellman_ford算法
[转载]字典树(trie树)、后缀树
求一个字符串中所有字符的组合
VS2013中修改.dll工程项目的.lib和.dll的输出路径
B-Tree、B+Tree和B*Tree
Copyright © 2011-2022 走看看