An event is a message raised by an object to signal the occurrence of an action. In order to receive event notifications, a caller must subscribe to the desired events.
The Xceed.FileSystem namespace defines four events that provide information about the status of an operation. These events are the ByteProgression event which provides information on the item being processed, the ItemProgression event which provides information on the item that is about to be processed, the ItemException event which is raised whenever an exception is caught during the processing of a list of items and the ScanningFolder event which is raised whenever a folder is scanned for matching items.
All these events are accessed through the FileSystemEvents class which dispatches the events that are raised to the subscribed callers.
The Xceed.Zip namespace defines five events that provide information about the status of an operation that deals with zip files. These events are the BuildingZipByteProgression event which is raised when the target zip file is being built, the BuildingZipItemProgression event which is raised each time a file is about to be added to the target zip file, the ReadingZipItemProgression event which is raised is raised whenever an item in a zipped folder is about to be read, the GatheringZipContentByteProgression event which is raised during the step preceding the actual creation of the target zip file, where files to keep from the original zip file (the ones that were not modified) are gathered to a temporary location before overwriting the zip file and the DiskRequired event which is raised when a new disk or split part is required.
All these events are accessed through the ZipEvents class which derives from the FileSystemEvents class and dispatches the events that are raised to the subscribed callers.
Keep in mind that you should subscribe only to the necessary events to prevent a reduction in performance.
The FileSystemEvents and ZipEvents classes dispatch the events that are raised to the callers that are subscribed to receive event notifications. If you want to call a method and receive its event notifications, it is important to use the method overload that takes a FileSystemEvents object as a parameter.
Each event has a corresponding delegate class that is used to subscribe to the event. To subscribe to an event, a new instance of the appropriate delegate class must be created and assigned to the corresponding event of the FileSystemEvents or ZipEvents object. In the constructor of the delegate class, we pass the name of the method that will handle the events raised by the event of the FileSystemEvents or ZipEvents object we are subscribing to.
Keep in mind that since the ZipEvents class derives from the FileSystemEvents class, it is also possible to subscribe to the events that the FileSystemEvents class implements.
Main article: Zipping items using multiple threads
Contrary to other events which are subscribed to by creating an instance of a FileSystemEvents class, the ParsingListingLine, CertificateRequired, and CertificateReceived events can only be subscribed to via the FtpConnection instance. If any other events are required, an instance of the FileSystemEvents class must be created and the desired events subscribed to.
The WaitingForAsyncOperation event is obsolete. The SynchronizingObject property should be used instead.