PowerTCP Zip Compression for .NET
Progress Event
Example 




Occurs to indicate the progress of the current compression or decompression activity.
Syntax
<DescriptionAttribute("Raised to report the progress of a zip or unzip operation.")>
<CategoryAttribute("Progress")>
Public Event Progress As ProgressEventHandler
Dim instance As Archive
Dim handler As ProgressEventHandler
 
AddHandler instance.Progress, handler
[Description("Raised to report the progress of a zip or unzip operation.")]
[Category("Progress")]
public event ProgressEventHandler Progress
[Description("Raised to report the progress of a zip or unzip operation.")]
[Category("Progress")]
public: __event ProgressEventHandler* Progress
[Description("Raised to report the progress of a zip or unzip operation.")]
[Category("Progress")]
public:
event ProgressEventHandler^ Progress
Event Data

The event handler receives an argument of type ProgressEventArgs containing data related to this event. The following ProgressEventArgs properties provide information specific to this event.

PropertyDescription
ItemThe ArchiveItem object currently being processed.  
ItemIndexThe index of the ArchiveItem object currently being processed.  
ProcessedItemBytesThe total uncompressed bytes already processed by the ArchiveItem.  
ProcessedTotalBytesThe cumulative number of bytes that have been processed in the Archive collection during the current operation.  
StatusThe status of the current on-going operation.  
TotalBytesThe total bytes to be processed for this operation.  
Remarks

A ProgressEventArgs object is passed to the event handler, containing details about the operation underway.

Not using the Progress event can improve the performance of your application as marshalling data from the worker thread to the UI thread will use available resources.

Example
The following example demonstrates using the Progress event.
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Zip"
' at the top of your class.

Private Sub Archive1_Progress(ByVal sender As Object, ByVal e As Dart.PowerTCP.Zip.ProgressEventArgs) Handles Archive1.Progress
    Try
        ' Set the progress bar and status when fires
        ' prgItem is the progress bar for an individual item and prgTotal is for all the items.
        Select Case (e.Status)

            Case Status.Unzipping
                ' Show item progress
                prgItem.Maximum = e.Item.Size
                prgItem.Value = e.processedItemBytes

                ' Show total progress
                prgTotal.Maximum = e.TotalBytes
                prgTotal.Value = e.ProcessedTotalBytes

                Debug.WriteLine("Unzipping " + e.Item.Name)
            Case Status.EndUnzip
                prgTotal.Value = prgTotal.Maximum
        End Select
    Catch

    End Try
End Sub
// Be sure to import the namespace by putting "using Dart.PowerTCP.Zip;"
// at the top of your class.

private void archive1_Progress(object sender, Dart.PowerTCP.Zip.ProgressEventArgs e)
		{
			try
			{
				// Set the progress bar and status when fires
				// prgItem is the progress bar for an individual item and prgTotal is for all the items.
				switch (e.Status)
				{
					case Status.Unzipping:
						// Show item progress
						prgItem.Maximum = (int)e.Item.Size;
						prgItem.Value = (int)e.ProcessedItemBytes;

						// Show total progress
						prgTotal.Maximum = (int)e.TotalBytes;
						prgTotal.Value = (int)e.ProcessedTotalBytes;

						Debug.WriteLine("Unzipping " + e.Item.Name);
						break;
					case Status.EndUnzip:
						prgTotal.Value = prgTotal.Maximum;
						break;
				}
			}
			catch {}
		}
See Also

Reference

Archive Class
Archive Members


PowerTCP Zip for .NET Documentation Version 2.1.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic