source: trunk/Include/Classes/System/Console.ab@ 435

Last change on this file since 435 was 435, checked in by イグトランス (egtra), 16 years ago

Consoleをスレッド安全化(クリティカルセクション使用)。
Exception.HResultをPublicにした。
StringBuilder.Replaceが正しく機能しない問題を解消。

File size: 1.5 KB
Line 
1'Classes/System/Console.ab
2
3Namespace System
4
5/*
6@brief コンソール入出力・ウィンドウなどのクラス
7@date 2008/02/26
8@auther Egtra
9*/
10Class Console
11Public
12 /*
13 @brief 標準入力を設定する
14 @date 2008/02/26
15 @auther Egtra
16 */
17 Static Sub SetIn(newIn As IO.TextReader)
18 If ActiveBasic.IsNothing(newIn) Then
19 Throw New ArgumentNullException("newIn")
20 End If
21 in = newIn
22 End Sub
23 /*
24 @brief 標準入力を取得する
25 @date 2008/02/26
26 @auther Egtra
27 */
28 Static Function In() As IO.TextReader
29 In = in
30 End Function
31
32 /*
33 @brief 標準入力から1行読み込む
34 @date 2008/02/26
35 @auther Egtra
36 */
37 Static Function ReadLine() As String
38 Dim lock = enter()
39 Try
40 ReadLine = in.ReadLine()
41 Finally
42 lock.Leave()
43 End Try
44 End Function
45
46 /*
47 @brief 標準入力から1行読み込む
48 @date 2008/02/26
49 @auther Egtra
50 */
51 Static Function Read() As Long
52 Dim lock = enter()
53 Try
54 Read = in.Read()
55 Finally
56 lock.Leave()
57 End Try
58 End Function
59Private
60 Function enter() As ActiveBasic.Windows.CriticalSectionLock
61 Imports ActiveBasic.Windows
62 If ActiveBasic.IsNothing(cs) Then
63 Dim lock = New CriticalSectionLock(_System_CriticalSection)
64 Try
65 If ActiveBasic.IsNothing(cs) Then
66 cs = New CriticalSection
67 End If
68 Finally
69 lock.Dispose()
70 End Try
71 End If
72 enter = cs.Enter
73 End Function
74
75 Static in = Nothing As IO.TextReader
76 Static cs = Nothing As ActiveBasic.Windows.CriticalSection
77End Class
78
79End Namespace 'System
Note: See TracBrowser for help on using the repository browser.