vb.netasynchronoussevenzipsharp

How can I use sevenzipsharp to asynchronously unzip a list of archives and dispose of them correctly?


How can I use SevenZipSharp to asynchronously unzip a list of archives and dispose of them correctly?

Here is what I'm looking at:

Public Class SevenZipVB

Private Shared extractors As New List(Of SevenZipVB)

Private WithEvents _extractor As SevenZip.SevenZipExtractor


''' <summary>
''' Extracts list of archives to their current directory always overwriting
''' </summary>
''' <param name="archives">List of full path names to archives</param>
Public Shared Sub BeginExtraction(ByVal archives As List(Of String))

    For Each archive In archives
        Dim ext = New SevenZipVB(archive)
        extractors.Add(ext)
    Next

    'magically wait for all extraction to finish but allow the calling thread to continue

End Sub

Private Sub New(ByVal archive As String)
    _extractor = New SevenZip.SevenZipExtractor(archive)
    _extractor.BeginExtractArchive(Path.GetDirectoryName(archive))
End Sub

Private Sub extractfinished() Handles _extractor.ExtractionFinished
    _extractor.Dispose()
End Sub

End Class

I guess I'll have to add some kind of async method but I don't know what it should look like. Any ideas?


Solution

  • Dont bother, that library is no longer supported, just use the command line 7za or 7zr