| IGLib 1.4 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | Private Attributes | Static Private Attributes

# IG::Lib::WaitFileEventBase Class Reference

Base class for classes that provide blocking until a file or directory is created/removed. More...

Inheritance diagram for IG::Lib::WaitFileEventBase:
[legend]
Collaboration diagram for IG::Lib::WaitFileEventBase:
[legend]

List of all members.

## 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.
override bool | Condition ()
| If not overridden, this condition always returns false.
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).
override void | CancelAll ()
| Cancel the current waiting for the condition on all threads.
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.
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.
override void | Wait ()
| Waits for condition to be fulfilled.
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.
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.
static void | ExampleBlockCreateRemove (string filePath, int numSwitches)
| Monitors the specified file and successively blocks until it is created and then until it is removed.
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.
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.
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.
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.
## Public Attributes
const System.IO.NotifyFilters | NotifyFiltersAll
| NotifyFilter enumeration that allows all kinds of events to be fired.
## Protected Member Functions
| WaitFileEventBase (string fileOrDirectoryPath)
virtual void | InitWaitFileEventBase (string fileOrDirectoryPath)
| Initializes the object appropriately. Overrride this method in derived classes!
string | EventToString (FileSystemEventArgs e)
virtual void | OnDeleted (object source, FileSystemEventArgs e)
| Handles events triggered when a file or directory is deleted.
virtual void | OnCreated (object source, FileSystemEventArgs e)
| Handles events triggered when a file or directory is created.
virtual void | OnChanged (object source, FileSystemEventArgs e)
| Handles events triggered when a file or directory is changed.
virtual void | OnRenamed (object source, RenamedEventArgs e)
| Handles events triggered when a file or directory is renamed.
void | OnError (object source, ErrorEventArgs e)
| Handles events triggered when an error occurs.
bool | ConditionInternal ()
| Wrapper around Condition() that enables control output to console.
## Protected Attributes
bool | _eventOccured = false
string | _fileOrDirectoryPath
| File or directory name.
## Properties
bool | PrintNotes`[get, set]`
| If true then various events and actions will be notified by console output (for testing purposes only!).
FileSystemWatcher | EventWatcher`[get]`
| Component that responds to file system events.
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).
static ThreadPulser | Pulser`[get]`
| Object that is used for pulsing.
object | TriggerLock`[get]`
| Locking object that is used for waiting trigging pulses that cause to check contition. Comes from Pulser.
virtual string | Path`[get, set]`
| Get or set path of the file on which the particular event is waited for.
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).
## Private Attributes
bool | _printNotes = false
FileSystemWatcher | _watcher = new FileSystemWatcher()
## Static Private Attributes
static ThreadPulser | _pulser = new ThreadPulser()

## Detailed Description

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)!

## Constructor & Destructor Documentation

IG::Lib::WaitFileEventBase::WaitFileEventBase | ( | string | fileOrDirectoryPath | ) | `[inline, protected]`

## Member Function Documentation

virtual void IG::Lib::WaitFileEventBase::InitWaitFileEventBase | ( | string | fileOrDirectoryPath | ) | `[inline, protected, virtual]`

Initializes the object appropriately. Overrride this method in derived classes!

Parameters:

  fileOrDirectoryPath |

Reimplemented in IG::Lib::WaitFileCreation, IG::Lib::WaitFileRemoval, IG::Lib::WaitDirectoryCreation, and IG::Lib::WaitDirectoryRemoval.

string IG::Lib::WaitFileEventBase::EventToString | ( | FileSystemEventArgs | e | ) | `[inline, protected]`

virtual void IG::Lib::WaitFileEventBase::OnDeleted | ( | object | source,
|  | FileSystemEventArgs | e
| ) |  | `[inline, protected, virtual]`

Handles events triggered when a file or directory is deleted.

virtual void IG::Lib::WaitFileEventBase::OnCreated | ( | object | source,
|  | FileSystemEventArgs | e
| ) |  | `[inline, protected, virtual]`

Handles events triggered when a file or directory is created.

virtual void IG::Lib::WaitFileEventBase::OnChanged | ( | object | source,
|  | FileSystemEventArgs | e
| ) |  | `[inline, protected, virtual]`

Handles events triggered when a file or directory is changed.

virtual void IG::Lib::WaitFileEventBase::OnRenamed | ( | object | source,
|  | RenamedEventArgs | e
| ) |  | `[inline, protected, virtual]`

Handles events triggered when a file or directory is renamed.

void IG::Lib::WaitFileEventBase::OnError | ( | object | source,
|  | ErrorEventArgs | e
| ) |  | `[inline, protected]`

Handles events triggered when an error occurs.

void IG::Lib::WaitFileEventBase::TriggerConditionCheck | ( |  | ) | `[inline]`

Triggers condition check by pulsing the object on which Wait() successively waits.

override bool IG::Lib::WaitFileEventBase::Condition | ( |  | ) | `[inline, virtual]`

If not overridden, this condition always returns false.

Implements IG::Lib::WaitConditionBase.

Reimplemented in IG::Lib::WaitFileCreation, IG::Lib::WaitFileRemoval, IG::Lib::WaitDirectoryCreation, and IG::Lib::WaitDirectoryRemoval.

bool IG::Lib::WaitFileEventBase::ConditionInternal | ( |  | ) | `[inline, protected]`

Wrapper around Condition() that enables control output to console.

override void IG::Lib::WaitFileEventBase::CancelOne | ( |  | ) | `[inline, virtual]`

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.

override void IG::Lib::WaitFileEventBase::CancelAll | ( |  | ) | `[inline, virtual]`

Cancel the current waiting for the condition on all threads.

Reimplemented from IG::Lib::WaitConditionBase.

void IG::Lib::WaitFileEventBase::WaitFirstEvent | ( |  | ) | `[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.

virtual void IG::Lib::WaitFileEventBase::WaitEvents | ( | int | numEvents | ) | `[inline, virtual]`

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.

override void IG::Lib::WaitFileEventBase::Wait | ( |  | ) | `[inline, virtual]`

Waits for condition to be fulfilled.

Implements IG::Lib::WaitConditionBase.

Reimplemented in IG::Lib::WaitFileCreation, IG::Lib::WaitFileRemoval, IG::Lib::WaitDirectoryCreation, and IG::Lib::WaitDirectoryRemoval.

override string IG::Lib::WaitFileEventBase::ToString | ( |  | ) | `[inline]`

static void IG::Lib::WaitFileEventBase::ExampleWaitEvents | ( | string | fileOrDirectoryPath,
|  | int | numEvents
| ) |  | `[inline, static]`

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.

static void IG::Lib::WaitFileEventBase::ExampleBlockCreateRemove | ( | string | filePath | ) | `[inline, static]`

Monitors the specified file and successively blocks until it is created and then until it is removed. This procedure is repeated twice.

Parameters:

  filePath | File whose creation and removal is monitored.

static void IG::Lib::WaitFileEventBase::ExampleBlockCreateRemove | ( | string | filePath,
|  | int | numSwitches
| ) |  | `[inline, static]`

Monitors the specified file and successively blocks until it is created and then until it is removed.

Parameters:

  filePath | File whose creation and removal is monitored.
  numSwitches | Number of iterations (creation/removal waits).

static void IG::Lib::WaitFileEventBase::ExampleBlockCreateRemove | ( | string | filePath,
|  | int | numSwitches,
|  | bool | waitDirectory
| ) |  | `[inline, static]`

Monitors the specified file and successively blocks until it is created and then until it is removed.

Parameters:

  filePath | File whose creation and removal is monitored.
  numSwitches | Number of iterations (creation/removal waits).
  directory | If true then creation/removal of a directory is waiting.

static void IG::Lib::WaitFileEventBase::TestSpeedBlockCreateRemove | ( | string | filePath | ) | `[inline, static]`

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.

Parameters:

  filePath | File whose creation and removal is monitored.

static void IG::Lib::WaitFileEventBase::TestSpeedBlockCreateRemove | ( | string | filePath,
|  | int | numSwitches,
|  | int | sleepMs
| ) |  | `[inline, static]`

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.

Parameters:

  filePath | File whose creation and removal is monitored.
  numSwitches | Number of iterations (creation/removal waits).
  sleepMs | Number of milliseconds to sleep between examples.

static void IG::Lib::WaitFileEventBase::TestSpeedBlockCreateRemove | ( | string | filePath,
|  | int | numSwitches,
|  | int | sleepMs,
|  | bool | waitDirectory
| ) |  | `[inline, static]`

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.

Parameters:

  filePath | File whose creation and removal is monitored.
  numSwitches | Number of iterations (creation/removal waits).
  sleepMs | Number of milliseconds to sleep between examples.
  directory | If true then creation/removal of a directory is waiting.

## Member Data Documentation

bool IG::Lib::WaitFileEventBase::_printNotes = false`[private]`

const System.IO.NotifyFilters IG::Lib::WaitFileEventBase::NotifyFiltersAll

Initial value:

                NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName |
                NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite |
                NotifyFilters.Security | NotifyFilters.Size

NotifyFilter enumeration that allows all kinds of events to be fired.

FileSystemWatcher IG::Lib::WaitFileEventBase::_watcher = new FileSystemWatcher()`[private]`

bool IG::Lib::WaitFileEventBase::_eventOccured = false`[protected]`

ThreadPulser IG::Lib::WaitFileEventBase::_pulser = new ThreadPulser()`[static, private]`

string IG::Lib::WaitFileEventBase::_fileOrDirectoryPath`[protected]`

File or directory name.

## Property Documentation

bool IG::Lib::WaitFileEventBase::PrintNotes`[get, set]`

If true then various events and actions will be notified by console output (for testing purposes only!).

FileSystemWatcher IG::Lib::WaitFileEventBase::EventWatcher`[get, protected]`

Component that responds to file system events.

virtual bool IG::Lib::WaitFileEventBase::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).

ThreadPulser IG::Lib::WaitFileEventBase::Pulser`[static, get, protected]`

Object that is used for pulsing.

object IG::Lib::WaitFileEventBase::TriggerLock`[get, protected]`

Locking object that is used for waiting trigging pulses that cause to check contition. Comes from Pulser.

virtual string IG::Lib::WaitFileEventBase::Path`[get, set]`

Get or set path of the file on which the particular event is waited for.

Implements IG::Lib::IWaitFileEvent.

bool IG::Lib::WaitFileEventBase::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).

The documentation for this class was generated from the following file:

- WaitConditionFile.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events