Class TDiscMonitorThread (unit DiscMon) |
=== DISC MONITORING THREAD =================================================== This thread will monitor a given directory and subdirectories (if required) for defined filtered changes. When a change occurs the OnChange event will be fired, if an invalid condition is found (eg non-existent path) then the OnInvalid event is fired. Each event is called via the Sychronize method and so are VCL thread safe. // The thread is created suspended, so after setting the required properties you must call the Resume method.
Constructors |
Functions |
Properties |
Events |
Variables |
Constructors |
=== MONITOR THREAD =========================================================== Create the thread suspended. Create two events, each are created using standard security, in the non-signalled state, with auto-reset and without names. The FDestroyEvent will be used to signal the thread that it is to close down. The FChangeEvent will be used to signal the thread when the monitoring conditions (directory, filters or sub-directory search) have changed. OnTerminate is left as false, so the user must Free the thread.
Functions |
close OnXXXXX links, signal the thread that it is to close down
The EXECUTE procedure ------- Execute needs to: 1. Call FindFirstChangeNotification and use the Handle in a WaitFor... to wait until the thread become signalled that a notification has occurred. The OnChange event is called and then the FindNextChangeNotification is the called and Execute loops back to the WaitFor 2. If an invalid handle is obtained from the above call, the the OnInvalid event is called and then Execute waits until valid conditions are set. 3. If a ChangeEvent is signalled then FindCloseChangeNotification is called, followed by a new FindFirstChangeNotification to use the altered conditions. 4. If a DestroyEvent is signalled then FindCloseChangeNotification is called and the two events are closed and the thread terminates. // In practice WaitForMultipleObjects is used to wait for any of the conditions to be signalled, and the returned value used to determine which event occurred.
On any of the above three changes, if the thread is running then signal it that a change has occurred.
called by the Execute procedure via Synchronize. So this is VCL thread safe
called by the Execute procedure via Synchronize. So this is VCL thread safe
Change the current directory
Change the current filters
Change the current sub-tree condition
Properties |
The directory to monitor
Filter condition, may be any of the FILE_NOTIFY_CHANGE_XXXXXXX constants ORed together. Zero is invalid.
Include subdirectories below specified directory.
Events |
Event called when change noted in directory
Event called for invalid parameters
Variables |