Forum Post: FileSystemWatcher issue - hanging

  • Thread starter Thread starter oedev
  • Start date Start date
Status
Not open for further replies.
O

oedev

Guest
Hello All, I have been working with the FileSystemWatcher class, and using a simple implementation can monitor a directory for file changes; USING Progress.Lang.*. CLASS FileSystemWatcher: DEFINE VARIABLE watcher AS System.IO.FileSystemWatcher. CONSTRUCTOR PUBLIC FileSystemWatcher() : DEFINE VARIABLE notifyEnum AS System.Enum NO-UNDO. MESSAGE "Watcher running" VIEW-AS ALERT-BOX INFORMATION. watcher = NEW System.IO.FileSystemWatcher(). watcher:Path = "c:\temp\watch". watcher:EnableRaisingEvents = TRUE. watcher:Filter = "*.*". notifyEnum = System.IO.NotifyFilters:FileName. notifyEnum = Progress.Util.EnumHelper:Or(notifyEnum, System.IO.NotifyFilters:LastAccess). notifyEnum = Progress.Util.EnumHelper:Or(notifyEnum, System.IO.NotifyFilters:LastWrite). notifyEnum = Progress.Util.EnumHelper:Or(notifyEnum, System.IO.NotifyFilters:DirectoryName). notifyEnum = Progress.Util.EnumHelper:Or(notifyEnum, System.IO.NotifyFilters:Attributes). watcher:NotifyFilter = CAST(notifyEnum, System.IO.NotifyFilters). watcher:Created:Subscribe(handler_File). watcher:Changed:Subscribe(handler_File). watcher:Renamed:Subscribe(handler_Renamed). WAIT-FOR System.Windows.Forms.Application:Run(). END. METHOD PRIVATE VOID handler_File(sender AS CLASS System.Object, e AS CLASS System.IO.FileSystemEventArgs): MESSAGE e:FullPath skip e:Name VIEW-AS ALERT-BOX INFORMATION. IF e:name = "stop.txt" THEN DO: MESSAGE "Stopping" VIEW-AS ALERT-BOX INFORMATION. QUIT. END. END METHOD. METHOD PRIVATE VOID handler_Renamed (sender AS CLASS System.Object, e AS CLASS System.IO.RenamedEventArgs): MESSAGE "Renamed" skip e:OldName skip e:Name skip e:FullPath skip VIEW-AS ALERT-BOX INFORMATION. IF e:name = "stop.txt" THEN DO: MESSAGE "Stopping" VIEW-AS ALERT-BOX INFORMATION. QUIT. END. END METHOD. END CLASS. However, when I try implement a directory watcher in a ABL Form, when the file handler event is raised then the session hangs. A debug message in the file handler method is displayed, but then the session hangs. Any ideas? Thanks!

Continue reading...
 
Status
Not open for further replies.
Back
Top