Last change
on this file since 471 was 435, checked in by イグトランス (egtra), 17 years ago |
Consoleをスレッド安全化(クリティカルセクション使用)。
Exception.HResultをPublicにした。
StringBuilder.Replaceが正しく機能しない問題を解消。
|
File size:
1.5 KB
|
Rev | Line | |
---|
[432] | 1 | 'Classes/System/Console.ab
|
---|
| 2 |
|
---|
| 3 | Namespace System
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
| 6 | @brief コンソール入出力・ウィンドウなどのクラス
|
---|
| 7 | @date 2008/02/26
|
---|
| 8 | @auther Egtra
|
---|
| 9 | */
|
---|
| 10 | Class Console
|
---|
| 11 | Public
|
---|
| 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
|
---|
[435] | 38 | Dim lock = enter()
|
---|
| 39 | Try
|
---|
| 40 | ReadLine = in.ReadLine()
|
---|
| 41 | Finally
|
---|
| 42 | lock.Leave()
|
---|
| 43 | End Try
|
---|
[432] | 44 | End Function
|
---|
[435] | 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
|
---|
[432] | 59 | Private
|
---|
[435] | 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 |
|
---|
[432] | 75 | Static in = Nothing As IO.TextReader
|
---|
[435] | 76 | Static cs = Nothing As ActiveBasic.Windows.CriticalSection
|
---|
[432] | 77 | End Class
|
---|
| 78 |
|
---|
| 79 | End Namespace 'System
|
---|
Note:
See
TracBrowser
for help on using the repository browser.