IGLib
1.7.2
The IGLib base library for development of numerical, technical and business applications.
|
Base class for classes that provide blocking until a file or directory is created/removed. More...
Classes | |
class | Example |
Class containing examples for waiting creation or removal of files and directories. More... | |
Public Member Functions | |
void | TriggerConditionCheck () |
Triggers condition check by pulsing the object on which Wait() successively waits. More... | |
override bool | Condition () |
If not overridden, this condition always returns false. More... | |
override void | CancelOne () |
Cancels the current waiting for the condition (if one is going on) and unblocks the thread on which waiting was called (possibly with some latency). More... | |
override void | CancelAll () |
Cancel the current waiting for the condition on all threads. More... | |
void | WaitFirstEvent () |
Blocks execution of the current thread until the first event is fired by the filesystem watcher. Enables raising events on the filesystem watcher, if not enabled. WARNING: This method is NOT thread safe. More... | |
virtual void | WaitEvents (int numEvents) |
Blocks execution of the current thread until the specified number of file system events are registered by the filesystem watcher. If the specified number of events is less than 1 then blicking is done ndefinitely (or until CancelWaiting() is called on the object from another thread). Enables raising events on the filesystem watcher, if not enabled. WARNING: This method is NOT thread safe. More... | |
override void | Wait () |
Waits for condition to be fulfilled. More... | |
override string | ToString () |
Static Public Member Functions | |
static void | ExampleWaitEvents (string fileOrDirectoryPath, int numEvents) |
Waits (blocks execution) until a given number of the specified file system events are registered. Basic information is printed for each event when it occurs. More... | |
static void | ExampleBlockCreateRemove (string filePath) |
Monitors the specified file and successively blocks until it is created and then until it is removed. This procedure is repeated twice. More... | |
static void | ExampleBlockCreateRemove (string filePath, int numSwitches) |
Monitors the specified file and successively blocks until it is created and then until it is removed. More... | |
static void | ExampleBlockCreateRemove (string filePath, int numSwitches, bool waitDirectory) |
Monitors the specified file and successively blocks until it is created and then until it is removed. More... | |
static void | TestSpeedBlockCreateRemove (string filePath) |
Test of speed of reaction of file/ directory creation and removal blocking waits. A specified number of alternate creations and removals are perfomed in a parallel thread, with specified delay between them. In the main thread, blocking waits are performed waiting for creation/removal in an infinite loop, and it is counted how many events are captured and how many are missed. More... | |
static void | TestSpeedBlockCreateRemove (string filePath, int numSwitches, int sleepMs) |
Test of speed of reaction of file/ directory creation and removal blocking waits. A specified number of alternate creations and removals are perfomed in a parallel thread, with specified delay between them. In the main thread, blocking waits are performed waiting for creation/removal in an infinite loop, and it is counted how many events are captured and how many are missed. More... | |
static void | TestSpeedBlockCreateRemove (string filePath, int numSwitches, int sleepMs, bool waitDirectory) |
Test of speed of reaction of file/ directory creation and removal blocking waits. A specified number of alternate creations and removals are perfomed in a parallel thread, with specified delay between them. In the main thread, blocking waits are performed waiting for creation/removal in an infinite loop, and it is counted how many events are captured and how many are missed. More... | |
Public Attributes | |
const System.IO.NotifyFilters | NotifyFiltersAll |
NotifyFilter enumeration that allows all kinds of events to be fired. More... | |
Protected Member Functions | |
WaitFileEventBase (string fileOrDirectoryPath) | |
virtual void | InitWaitFileEventBase (string fileOrDirectoryPath) |
Initializes the object appropriately. Overrride this method in derived classes! More... | |
string | EventToString (FileSystemEventArgs e) |
virtual void | OnDeleted (object source, FileSystemEventArgs e) |
Handles events triggered when a file or directory is deleted. More... | |
virtual void | OnCreated (object source, FileSystemEventArgs e) |
Handles events triggered when a file or directory is created. More... | |
virtual void | OnChanged (object source, FileSystemEventArgs e) |
Handles events triggered when a file or directory is changed. More... | |
virtual void | OnRenamed (object source, RenamedEventArgs e) |
Handles events triggered when a file or directory is renamed. More... | |
void | OnError (object source, ErrorEventArgs e) |
Handles events triggered when an error occurs. More... | |
bool | ConditionInternal () |
Wrapper around Condition() that enables control output to console. More... | |
Protected Attributes | |
bool | _eventOccured = false |
string | _fileOrDirectoryPath |
File or directory name. More... | |
Properties | |
bool | PrintNotes [get, set] |
If true then various events and actions will be notified by console output (for testing purposes only!). More... | |
FileSystemWatcher | EventWatcher [get] |
Component that responds to file system events. More... | |
virtual bool | EventOccured [get, set] |
This flag is set by event handlers, and can be used by waiting procedures to check if the current event has been triggered by the EventWatcher installed on the other object (since registration of events of all other EventWatchers is done on the same thread). More... | |
static ThreadPulser | Pulser [get] |
Object that is used for pulsing. More... | |
object | TriggerLock [get] |
Locking object that is used for waiting trigging pulses that cause to check contition. Comes from Pulser. More... | |
virtual string | Path [get, set] |
Get or set path of the file on which the particular event is waited for. More... | |
bool | EnableRaisingEvents [get, set] |
If true, events are raised by file system watched, otherwise events are not raised. This flag can not be set when in the stage of waiting. Attpmpt of doing so has no effect (also does not throw an exception). More... | |
Properties inherited from IG.Lib.WaitConditionBase | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More... | |
object | InternalLock [get] |
Used internally for locking access to internal fields. More... | |
object | WaitLock [get] |
Must be used only for locking waiting the Waiting() block (since it is potentially time consuming). More... | |
virtual bool | IsWaiting [get, protected set] |
True if waiting for unblocking condition is currently performed, and false otherwise. Setting should only be done within the waiting function. More... | |
virtual bool | CancelFlag [get, set] |
If this flag is set then the current waiting (if one is going on) will be cancelled. More... | |
Properties inherited from IG.Lib.IWaitCondition | |
bool | IsWaiting [get] |
Returns true if waiting for unblocking condition is currently performed, and false otherwise. Setting should only be done within the waiting function. More... | |
Properties inherited from IG.Lib.ILockable | |
object | Lock [get] |
Properties inherited from IG.Lib.IWaitFileEvent | |
string | Path [get, set] |
Path of the file or directory on which the particular event is waited for. Can be specified as relative path, but is internally stored as fully qualified path. More... | |
Private Attributes | |
bool | _printNotes = false |
FileSystemWatcher | _watcher = new FileSystemWatcher() |
Static Private Attributes | |
static ThreadPulser | _pulser = new ThreadPulser() |
Base class for classes that provide blocking until a file or directory is created/removed.
$A Igor Jun10; TODO: implement non-latence vaiting (via file events)!
|
inlineprotected |
|
inlineprotectedvirtual |
Initializes the object appropriately. Overrride this method in derived classes!
fileOrDirectoryPath |
Reimplemented in IG.Lib.WaitDirectoryRemoval, IG.Lib.WaitDirectoryCreation, IG.Lib.WaitFileRemoval, and IG.Lib.WaitFileCreation.
|
inlineprotected |
|
inlineprotectedvirtual |
Handles events triggered when a file or directory is deleted.
|
inlineprotectedvirtual |
Handles events triggered when a file or directory is created.
|
inlineprotectedvirtual |
Handles events triggered when a file or directory is changed.
|
inlineprotectedvirtual |
Handles events triggered when a file or directory is renamed.
|
inlineprotected |
Handles events triggered when an error occurs.
|
inline |
Triggers condition check by pulsing the object on which Wait() successively waits.
|
inlinevirtual |
If not overridden, this condition always returns false.
Implements IG.Lib.WaitConditionBase.
Reimplemented in IG.Lib.WaitDirectoryRemoval, IG.Lib.WaitDirectoryCreation, IG.Lib.WaitFileRemoval, and IG.Lib.WaitFileCreation.
|
inlineprotected |
Wrapper around Condition() that enables control output to console.
|
inlinevirtual |
Cancels the current waiting for the condition (if one is going on) and unblocks the thread on which waiting was called (possibly with some latency).
Reimplemented from IG.Lib.WaitConditionBase.
|
inlinevirtual |
Cancel the current waiting for the condition on all threads.
Reimplemented from IG.Lib.WaitConditionBase.
|
inline |
Blocks execution of the current thread until the first event is fired by the filesystem watcher. Enables raising events on the filesystem watcher, if not enabled. WARNING: This method is NOT thread safe.
|
inlinevirtual |
Blocks execution of the current thread until the specified number of file system events are registered by the filesystem watcher. If the specified number of events is less than 1 then blicking is done ndefinitely (or until CancelWaiting() is called on the object from another thread). Enables raising events on the filesystem watcher, if not enabled. WARNING: This method is NOT thread safe.
Referenced by IG.Lib.WaitFileEventBase.ExampleWaitEvents().
|
inlinevirtual |
Waits for condition to be fulfilled.
Implements IG.Lib.WaitConditionBase.
Reimplemented in IG.Lib.WaitDirectoryRemoval, IG.Lib.WaitDirectoryCreation, IG.Lib.WaitFileRemoval, and IG.Lib.WaitFileCreation.
|
inline |
|
inlinestatic |
Waits (blocks execution) until a given number of the specified file system events are registered. Basic information is printed for each event when it occurs.
References IG.Lib.WaitFileEventBase.EnableRaisingEvents, IG.Lib.WaitFileEventBase.EventWatcher, IG.Lib.WaitFileEventBase.Path, IG.Lib.WaitFileEventBase.PrintNotes, and IG.Lib.WaitFileEventBase.WaitEvents().
Referenced by IG.Script.ScriptAppBase.FileFunctionLogEvents().
|
inlinestatic |
Monitors the specified file and successively blocks until it is created and then until it is removed. This procedure is repeated twice.
filePath | File whose creation and removal is monitored. |
References IG.Lib.WaitFileEventLatenceBase.ExampleLatence.ExampleBlockCreateRemove().
|
inlinestatic |
Monitors the specified file and successively blocks until it is created and then until it is removed.
filePath | File whose creation and removal is monitored. |
numSwitches | Number of iterations (creation/removal waits). |
References IG.Lib.WaitFileEventLatenceBase.ExampleLatence.ExampleBlockCreateRemove().
|
inlinestatic |
Monitors the specified file and successively blocks until it is created and then until it is removed.
filePath | File whose creation and removal is monitored. |
numSwitches | Number of iterations (creation/removal waits). |
waitDirectory | If true then creation/removal of a directory is waiting. |
References IG.Lib.WaitFileEventLatenceBase.ExampleLatence.ExampleBlockCreateRemove().
|
inlinestatic |
Test of speed of reaction of file/ directory creation and removal blocking waits. A specified number of alternate creations and removals are perfomed in a parallel thread, with specified delay between them. In the main thread, blocking waits are performed waiting for creation/removal in an infinite loop, and it is counted how many events are captured and how many are missed.
filePath | File whose creation and removal is monitored. |
References IG.Lib.WaitFileEventLatenceBase.ExampleLatence.TestSpeedBlockCreateRemove().
|
inlinestatic |
Test of speed of reaction of file/ directory creation and removal blocking waits. A specified number of alternate creations and removals are perfomed in a parallel thread, with specified delay between them. In the main thread, blocking waits are performed waiting for creation/removal in an infinite loop, and it is counted how many events are captured and how many are missed.
filePath | File whose creation and removal is monitored. |
numSwitches | Number of iterations (creation/removal waits). |
sleepMs | Number of milliseconds to sleep between examples. |
References IG.Lib.WaitFileEventLatenceBase.ExampleLatence.TestSpeedBlockCreateRemove().
|
inlinestatic |
Test of speed of reaction of file/ directory creation and removal blocking waits. A specified number of alternate creations and removals are perfomed in a parallel thread, with specified delay between them. In the main thread, blocking waits are performed waiting for creation/removal in an infinite loop, and it is counted how many events are captured and how many are missed.
filePath | File whose creation and removal is monitored. |
numSwitches | Number of iterations (creation/removal waits). |
sleepMs | Number of milliseconds to sleep between examples. |
waitDirectory | If true then creation/removal of a directory is waiting. |
References IG.Lib.WaitFileEventLatenceBase.ExampleLatence.TestSpeedBlockCreateRemove().
|
private |
const System.IO.NotifyFilters IG.Lib.WaitFileEventBase.NotifyFiltersAll |
NotifyFilter enumeration that allows all kinds of events to be fired.
|
private |
|
protected |
|
staticprivate |
|
protected |
File or directory name.
|
getset |
If true then various events and actions will be notified by console output (for testing purposes only!).
Referenced by IG.Lib.WaitFileEventBase.ExampleWaitEvents().
|
getprotected |
Component that responds to file system events.
Referenced by IG.Lib.WaitFileEventBase.ExampleWaitEvents().
|
getset |
This flag is set by event handlers, and can be used by waiting procedures to check if the current event has been triggered by the EventWatcher installed on the other object (since registration of events of all other EventWatchers is done on the same thread).
|
staticgetprotected |
Object that is used for pulsing.
|
getprotected |
Locking object that is used for waiting trigging pulses that cause to check contition. Comes from Pulser.
|
getset |
Get or set path of the file on which the particular event is waited for.
Referenced by IG.Lib.WaitFileEventBase.ExampleWaitEvents().
|
getset |
If true, events are raised by file system watched, otherwise events are not raised. This flag can not be set when in the stage of waiting. Attpmpt of doing so has no effect (also does not throw an exception).
Referenced by IG.Lib.WaitFileEventBase.ExampleWaitEvents().