This class is a 100% static placeholder for global methods and fields of ALib. Among the things implemented here are:
Public Static Fields | |
static Configuration | Config =null |
static AString | ConfigCategory = new AString( "ALIB" ) |
static readonly int | MainThreadID = Thread.CurrentThread.ManagedThreadId |
static readonly int | Revision =0 |
static SmartLock | StdOutputStreamsLock = new SmartLock() |
static readonly int | Version =2402 |
static VariableDecl | WAIT_FOR_KEY_PRESS |
static bool | WaitForKeyPressOnTermination |
Public Static Methods | |
static void | Init (Configuration config) |
static void | Init (String[] args=null) |
static bool | IsWindowsOS () |
static bool | ReadBoolean (Substring src) |
static Case | ReadCase (Substring src) |
static Inclusion | ReadInclusion (Substring src) |
static void | Sleep (Ticks ticks) |
static void | SleepMicros (long microsecs) |
static void | SleepMillis (int millisecs) |
static void | SleepNanos (long nanosecs) |
static void | TerminationCleanUp () |
Private Static Fields | |
static ? bool | _sysInfo_HasConsoleWindow |
static bool | isInitialized = false |
static char[] | trueValuesBoolean = { 't', '1', 'y' } |
static char[] | trueValuesCase = { 's', 't', '1', 'y' } |
static char[] | trueValuesInclusion = { 'i', 't', '1', 'y' } |
Private Static Methods | |
static void | init () |
Properties | |
static bool | HasConsoleWindow [get] |
|
inlinestaticprivate |
Used by Init functions.
|
inlinestatic |
|
inlinestatic |
This method must be called prior to using ALib, e.g. at the beginning of the main()
method of an application. It is OK, to call this method more than once, which allows independent code blocks (e.g. libraries) to bootstrap ALIB independently. However, only the first invocation is effective
The very first invocation should not be interrupted by a parallel invocation of a second thread. Consequently, with more complex applications it is recommended to explicitly invoke this method once when the software is bootstrapped.
If command line parameters should be used for configuring ALox, then the very first call to this method has to provide the argc and argv parameters. Subsequent calls to this method with different parameters do not change the setup.
If other, custom configuration data sources should be used already with this method use overloaded method ALIB.Init(Configuration).
WAIT_FOR_KEY_PRESS
.args | Parameters taken from standard C# method main() (the list of command line arguments). Defaults to null. |
|
inlinestatic |
Detects if this is running on Windows OS.
true
if the calling process is running on Windows
|
inlinestatic |
Interprets given src as a boolean value. enums.Inclusion. If the case insensitive comparison of the first non-whitespace characters of the string with with values "t", "1", "y", "on", "ok" matches, true
is returned. Otherwise, including the case that src is 'nulled', false
is returned.
src | The string to 'parse'. |
Interprets given src as a value of enum type enums.Case. If the case insensitive comparison of the first non-whitespace characters of the string with values "s", "y", "t", "1" matches, Case.Sensitive is returned. Otherwise, including the case that src is 'nulled', Case.Ignore is returned.
src | The string to 'parse'. |
Interprets given src as a value of enum type enums.Inclusion. If the case insensitive comparison of the first non-whitespace characters of the string with values "i", "y", "t", "1" matches, Inclusion.Include is returned. Otherwise, including the case that src is 'nulled', Inclusion.Exclude is returned.
src | The string to 'parse'. |
|
inlinestatic |
Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are SleepMillis, SleepMicros and SleepNanos.
ticks | Sleep time in Ticks. |
|
inlinestatic |
Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are Sleep, SleepMillis and SleepNanos.
microsecs | Sleep time in microseconds. |
|
inlinestatic |
Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are Sleep, SleepMicros and SleepNanos.
millisecs | Sleep time in milliseconds. |
|
inlinestatic |
Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are Sleep, SleepMillis and SleepMicros.
nanosecs | Sleep time in microseconds. |
|
inlinestatic |
Got nothing to do in C#.
|
staticprivate |
Internal flag used to by property HasConsoleWindow
|
static |
The configuration used by ALox. This is received or created with overloaded Init methods. It might be shared with other libraries or can be an instance explicitly dedicated to the ALox library.
The option to use an exclusive one may be used to store ALox configuration variables in different configuration files, e.g. to reduce "clutter" of an applications' then "main" configuration file.
Changes should only be made at very initial, single threaded bootstrap code, with the invocation of the according method Init(Configuration).
The name of the configuration category of configuration variables used by the AWorx library.
Defaults to "ALIB".
6 This value can be changed to avoid conflicts between applications (especially in respect to environment variable settings). Changes should be placed at very initial bootstrap code, before the invocation of Init.
|
staticprivate |
State of initialization, used to avoid double initialization.
|
static |
The ID of the thread that initialized this static field. This is supposedly the "main" thread.
|
static |
This is a smart mutex that allows to lock an applications' standard output streams.
In multi-threaded processes, to protect the output streams from concurrent access, this smart lock might be used by any entity that writes data to the streams. Before it can be used (acquired and released), it is needed to register with the object using SmartLock.AddAcquirer. This has to be done once per thread that aims to write to the stream. Then, prior to writing, this object has to be acquired and after writing released.
Because often, the standard output stream and standard error stream are identical, ALib provides one single lock for both, to protect also against interwoven standard output and error information.
If the 'entity' that is registering is not of type ThreadLock it is allowed to provide null
in the parameter of method AddAcquirer. In this case, the process of adding and removing acquirers is not performed in a thread safe way. Therefore it is advised to register so called anonymous (null
) acquirers only at bootstrap time, when no parallel threads were started, yet.
If an application is deemed to always write to the standard output streams from within multiple threads, an alternative to registering each writing entity, is to invoke AddAcquirer just two times in a row with null
at the start of a process and then never do this again (and never de-register). This way, no thread needs to register/deregister but threads may still Acquire and Release the lock without being registered. In other words, once a smart lock is enabled, subsequent registrations are just used to count and identify the de-registration.
Console.WriteLine
, should register at bootstrap and acquire this instance prior to writing. This way, log output and other application output is not mixed, but separated in different Lines.
|
staticprivate |
Strings used to identify a boolean value from a string representation
|
staticprivate |
Strings used to identify an enum Case from a string representation
|
staticprivate |
Strings used to identify an enum Inclusion from a string representation
|
static |
The ALib version. The versioning follows the scheme YYMM (2-digit year, 2-digit month) of the initial release date. Besides this version number, field Revision indicates if this is a revised version of a former release.
|
static |
Configuration variable declaration.
|
static |
If true, within TerminationCleanUp, it is waited for a key press in the console window.
By default, this flag is enabled when debugging a console application under Visual Studio.
This default behavior can be overruled by setting configuration variable ALIB_WAIT_FOR_KEY_PRESS.
In addition, this public flag may be modified at runtime.
|
staticget |
Determines if a console is attached to this process