VB'deki İyonik Sınıfı kullanarak bir dosyayı sıkıştırıyorum. Kayıt ilerlemesini GUI'ye bildirmek istedim. zip.SaveProgress olayını Sub ProgessChanged ile işledim. Ana iş parçasında çalıştı, ama onu çalışan iş parçacığına kaydırmam gerekiyor. Bir iş parçacığı içinde nasıl eklenir?
Bu
ben bağladılar budur ..Dim foldertozip As String
Dim zipfileaddress As String
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectFile_BT.Click
Dim th As Thread = New Thread(AddressOf ZipUp)
th.Start()
End Sub
Public Sub ZipUp()
Dim zip As ZipFile = New ZipFile
AddHandler zip.SaveProgress, AddressOf ProgressUpdater
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestSpeed
zip.BufferSize = My.Settings.BufferSize
zip.AddDirectory(foldertozip)
zip.Save(zipfileaddress)
End Sub
Public Shared Sub ProgressUpdater(ByVal sender As Object, ByVal e As SaveProgressEventArgs)
If (e.EventType = ZipProgressEventType.Saving_Completed) Then
Return
ElseIf (e.EventType = ZipProgressEventType.Saving_BeforeWriteEntry) Then
Status.Label1.Text = e.CurrentEntry.FileName
ElseIf (e.EventType = ZipProgressEventType.Saving_EntryBytesRead) Then
Status.PercentLabel.Text = CStr(CInt(e.BytesTransferred)/(0.01 * e.TotalBytesToTransfer))
Status.ProgressBar1.Value = CInt(CInt(e.BytesTransferred)/(0.01 * e.TotalBytesToTransfer))
End If
End Sub
Ben parçacığı ile çok aşina değilim ...
Teşekkür