EDITO:Ya lo he arreglado, era culpa de la maldita barra de progreso extendida y su propiedad "textshow",si le sumaba un valor sin que hubiera ningún valor que mostrar, da error".
Saludos!
Pues no, con lo de antes no me equivocaba, me salta error hasta por esto!:
Thread_Split.Start()
MsgBox("a")
El msgbox me salta error de operación aritmética, juas!!!! no lo entiendo...
Ahora mismo me encuentro tocando todo el thread para intentar solucionarlo, lo siento si no es muy bonito ni uso técnicas tán avanzadas como la que ha comentado
Kubox xD...
Este es el botón que llama al thread, bueno, es un botón para llamarlo, y otro para abortarlo.
#Region " Button Split "
' Button SPLIT
Private Sub Button_Split_ClickButtonArea(Sender As Object, e As MouseEventArgs) Handles Button_Split.ClickButtonArea
'Try : Thread_Split.Abort() : Catch : End Try
Thread_is_completed = False
Thread_Split = New Threading.Thread(AddressOf Split_Thread)
Thread_Split.IsBackground = True
Thread_Split.Start()
MsgBox("a") ' esto da error cuando inicio el thread por segunda vez....juas...
While Not Thread_is_completed = True
Application.DoEvents()
End While
'Thread_is_completed = True
Want_to_cancel_thread = False
End Sub
' Button STOP
Private Sub Button_Stop_ClickButtonArea(Sender As Object, e As MouseEventArgs) Handles Button_Stop.ClickButtonArea
Want_to_cancel_thread = True
' Try : Thread_Split.Abort() : Catch : End Try
' Thread_is_completed = True
Kill_Process("7z")
Kill_Process("rar")
End Sub
#End Region
el thread:
#Region " Split Thread "
Sub Split_Thread()
TotalFiles_Number = 0
If Copy_Mode = "Copy" Or Copy_Mode = "Move" And Not Want_to_cancel_thread = True Then
If Not Want_to_cancel_thread = True Then
Get_All_Files(New IO.DirectoryInfo(Selected_Directory))
' ProgressBar
InvokeControl(ProgBarPlus, Sub(x) x.Max = TotalFiles_Number)
If Copy_Mode = "Copy" Then : InvokeControl(ProgBarPlus, Sub(x) x.TextFormat = "Copying {0} of {2} files")
ElseIf Copy_Mode = "Move" Then : InvokeControl(ProgBarPlus, Sub(x) x.TextFormat = "Moving {0} of {2} files")
End If
InvokeControl(ProgBarPlus, Sub(x) x.TextShow = ProgBar.ProgBarPlus.eTextShow.FormatString)
' Copy /Move
Dim FolderNum As Integer = 1
For Each File In Files_List
If Not Want_to_cancel_thread = True Then
Cached_Size
+= File.
Split("|")(2) If Not Cached_Size >= Selected_Disc_Bytes Then
If Copy_Mode
= "Copy" Then Copy_File
(File.
Split("|")(0) & "\" & File.
Split("|")(1), Selected_Output_Directory
& "\Disc " & FolderNum
& Get_File_Info
(File.
Split("|")(0) & "\" & File.
Split("|")(1), DirectoryName
).
ToString.
Split(":")(1),
True,
True) 'If Copy_Mode = "Move" Then Move_File(File.Split("|")(0) & "\" & File.Split("|")(1), Selected_Output_Directory & "\Disc " & FolderNum & Get_File_Info(File.Split("|")(0) & "\" & File.Split("|")(1), DirectoryName).ToString.Split(":")(1), True, True)
Else
Cached_Size = Nothing
FolderNum += 1
If Copy_Mode
= "Copy" Then Copy_File
(File.
Split("|")(0) & "\" & File.
Split("|")(1), Selected_Output_Directory
& "\Disc " & FolderNum
& Get_File_Info
(File.
Split("|")(0) & "\" & File.
Split("|")(1), DirectoryName
).
ToString.
Split(":")(1),
True,
True) 'If Copy_Mode = "Move" Then Move_File(File.Split("|")(0) & "\" & File.Split("|")(1), Selected_Output_Directory & "\Disc " & FolderNum & Get_File_Info(File.Split("|")(0) & "\" & File.Split("|")(1), DirectoryName).ToString.Split(":")(1), True, True)
End If
InvokeControl(ProgBarPlus, Sub(x) x.Value += 1)
Else
Want_to_cancel_thread = False
Thread_is_completed = True
'Try : Thread_Split.Abort() : Catch : End Try
Exit For
End If
Next
End If
ElseIf Copy_Mode = "7Zip" And Not Want_to_cancel_thread = True Then
InvokeControl(ProgBarPlus, Sub(x) x.TextFormat = "Progress is not avaliable for 7Zip")
InvokeControl(ProgBarPlus, Sub(x) x.TextShow = ProgBar.ProgBarPlus.eTextShow.FormatString)
Run_Process("7z.exe", " a " & """" & Selected_Output_Directory & "\Disc.7z" & """" & " " & """" & Selected_Directory & """" & " -v" & Selected_Disc_Bytes.ToString & "b " & " -m0=BCJ -bd -y", False, True)
ElseIf Copy_Mode = "Rar" And Not Want_to_cancel_thread = True Then
InvokeControl(ProgBarPlus, Sub(x) x.TextFormat = "Progress is not avaliable for Rar")
InvokeControl(ProgBarPlus, Sub(x) x.TextShow = ProgBar.ProgBarPlus.eTextShow.FormatString)
Run_Process("RAR.exe", " a " & """" & Selected_Output_Directory & "\Disc.rar" & """" & " " & """" & Selected_Directory & """" & " -v" & Selected_Disc_Bytes.ToString & "b " & " -m0 -ibck -o+", False, True)
ElseIf Copy_Mode = "Exe" And Not Want_to_cancel_thread = True Then
InvokeControl(ProgBarPlus, Sub(x) x.TextFormat = "Progress is not avaliable for Exe")
InvokeControl(ProgBarPlus, Sub(x) x.TextShow = ProgBar.ProgBarPlus.eTextShow.FormatString)
Run_Process("RAR.exe", " a -sfx " & """" & Selected_Output_Directory & "\Disc.exe" & """" & " " & """" & Selected_Directory & """" & " -v" & Selected_Disc_Bytes.ToString & "b " & " -m0 -ibck -o+", False, True)
End If
MessageBox.Show("All files compressed", "Splitty 1.2", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Want_to_cancel_thread = False
Thread_is_completed = True
'Try : Thread_Split.Abort() : Catch : End Try
'Exit Sub
End Sub
#End Region