Ignore:
Timestamp:
Feb 28, 2008, 1:39:16 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/Console.ab

    r432 r435  
    3636    */
    3737    Static Function ReadLine() As String
    38         ReadLine = in.ReadLine()
     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
    3958    End Function
    4059Private
     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
    4175    Static in = Nothing As IO.TextReader
     76    Static cs = Nothing As ActiveBasic.Windows.CriticalSection
    4277End Class
    4378
Note: See TracChangeset for help on using the changeset viewer.