//
--------------------------------------------------------------------
//
All Rights Reserved , Copyright (C) 2011 , Hairihan TECH, Ltd.
//
--------------------------------------------------------------------
namespace
DotNet.Example
{
using
DotNet.BaseManager;
public
class
StaticTest
{
///
<summary>
///
定义委托
///
</summary>
///
<param name="user">
用户
</param>
delegate
void
MakeStaticDelegate(
string
user);
///
<summary>
///
这里是测试静态方法
///
</summary>
///
<param name="user">
用户
</param>
private
static
void
MakeStaticTest(
string
user)
{
for
(
int
i
=
0
; i
<
10
; i
++
)
{
//
输出当前的变量
System.Console.WriteLine(user
+
"
:
"
+
i.ToString());
System.Threading.Thread.Sleep(
1000
);
}
}
///
<summary>
///
这里是模拟多用户同时点击并发
///
</summary>
public
void
DoTest()
{
//
模拟3个用户的并发操做
MakeStaticDelegate makeStaticDelegate1
=
new
MakeStaticDelegate(MakeStaticTest);
makeStaticDelegate1.BeginInvoke(
"
user1
"
,
null
,
null
);
MakeStaticDelegate makeStaticDelegate2
=
new
MakeStaticDelegate(MakeStaticTest);
makeStaticDelegate2.BeginInvoke(
"
user2
"
,
null
,
null
);
MakeStaticDelegate makeStaticDelegate3
=
new
MakeStaticDelegate(MakeStaticTest);
makeStaticDelegate3.BeginInvoke(
"
user3
"
,
null
,
null
);
System.Console.ReadLine();
}
}