Class Lz4LoadOptions
Class Lz4LoadOptions
Namespace: Aspose.Zip.Lz4
Assembly: Aspose.Zip.dll (25.7.0)
Options for loading Aspose.Zip.Lz4.Lz4Archive.
public class Lz4LoadOptions
Inheritance
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
Lz4LoadOptions()
public Lz4LoadOptions()
Properties
CancellationToken
Gets or sets a cancellation token used to cancel the extraction operation.
public CancellationToken CancellationToken { get; set; }
Property Value
Examples
Cancel lz4 archive extraction after a certain time.
using (CancellationTokenSource cts = new CancellationTokenSource())
{
cts.CancelAfter(TimeSpan.FromSeconds(60));
using (var a = new Lz4Archive("big.lz4", new Lz4LoadOptions() { CancellationToken = cts.Token }))
{
try
{
a.Extract("data.bin");
}
catch(OperationCanceledException)
{
Console.WriteLine("Extraction was cancelled after 60 seconds");
}
}
}
```<p>
Using with <code>Task</code>
```csharp
CancellationTokenSource cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(60));
Task t = Task.Run(delegate()
{
var loadOptions = new Lz4LoadOptions() { CancellationToken = cts.Token };
using (var a = Lz4Archive("big.lz4", loadOptions))
{
a.ExtractToDirectory("destination");
}
}, cts.Token);
t.ContinueWith(delegate(Task antecedent)
{
if (antecedent.IsCanceled)
{
Console.WriteLine("Extraction was cancelled after 60 seconds");
}
cts.Dispose();
});
```</p>
Cancellation mostly results in some data not being extracted.
#### Remarks
This property exists for .NET Framework 4.0 and above.