//
--------------------------------------------------------------------
//
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();
}
}