Bonjour,
Je cherche quelqu'un qui serait capable de me faire fonctionner cela correctement (problème décrit à la fin) :
Public Class bin2hex
Dim processes As Process
Dim Thread1 As System.Threading.Thread
Dim Thread2 As System.Threading.Thread
Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
OFD.InitialDirectory = My.Application.Info.DirectoryPath
OFD.ShowDialog()
txtIN.Text = OFD.FileName
End Sub
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
SFD.FileName = txtIN.Text & ".hex"
SFD.ShowDialog()
txtOUT.Text = SFD.FileName
End Sub
Private Sub Process_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Process.Click
Dim input() As Byte = IO.File.ReadAllBytes(txtIN.Text)
Dim output As String = ""
PB.Visible = True
PB.Maximum = input.Length + 2
processes = New Process(input)
CheckForIllegalCrossThreadCalls = False
AddHandler processes.Progress, AddressOf progress
Thread1 = New System.Threading.Thread(AddressOf processes.thread1)
Thread1.Start()
Thread2 = New System.Threading.Thread(AddressOf processes.thread2)
Thread2.Start()
End Sub
Sub progress(ByVal pos As Long)
Try
PB.Value = pos
Speed1.Text = "Thread1 : " & Int(processes.totalcalc1 / processes.totaltime1) & "calc/ms"
Speed2.Text = "Thread2 : " & Int(processes.totalcalc2 / processes.totaltime2) & "calc/ms"
Catch
End Try
Application.DoEvents()
If pos >= processes.input.Length - 1 Then
IO.File.WriteAllText(txtOUT.Text, processes.output)
Try
If My.Application.CommandLineArgs(0) <> ""And My.Application.CommandLineArgs(1) <> ""Then End
Catch
End Try
MsgBox("Finished !", MsgBoxStyle.Information)
PB.Visible = False
Thread1.Abort()
Thread2.Abort()
End If
End Sub
Private Sub bin2hex_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
If My.Application.CommandLineArgs(0) <> ""And My.Application.CommandLineArgs(1) <> ""Then
txtIN.Text = My.Application.CommandLineArgs(0)
txtOUT.Text = My.Application.CommandLineArgs(1)
My.Application.DoEvents()
Process_Click(sender, e)
End If
Catch
End Try
End Sub
End Class
Public Class process
Public input() AsByte
Public output() AsChar
Public working1 AsBoolean
Public working2 AsBoolean
Dim watch1 As New Diagnostics.Stopwatch
Dim watch2 As New Diagnostics.Stopwatch
Public totaltime1 As Long
Public totaltime2 As Long
Public totalcalc1 As Long
Public totalcalc2 As Long
Dim pos As Long = -1
Sub New(ByVal _input() As Byte)
input = _input
ReDim output(((input.Length - 1) * 2) + 1)
End Sub
Sub thread1()
While pos < input.Length - 1
working1 = True
pos += 1
watch1.Reset()
watch1.Start()
Dim MyPos As Long = pos
Dim hexa As String = Hex(input(MyPos))
If hexa.Length < 2 Then
output(MyPos * 2) = "0"
output((MyPos * 2) + 1) = hexa
Else
output(MyPos * 2) = Mid(hexa, 1, 1)
output((MyPos * 2) + 1) = Mid(hexa, 2, 1)
End If
watch1.Stop()
totaltime1 += watch1.ElapsedMilliseconds
totalcalc1 += 1
RaiseEvent Progress(pos)
working1 = False
End While
End Sub
Sub thread2()
While pos < input.Length - 1
working2 = True
pos += 1
watch2.Reset()
watch2.Start()
Dim MyPos As Long = pos
Dim hexa As String = Hex(input(MyPos))
If hexa.Length < 2 Then
output(MyPos * 2) = "0"
output((MyPos * 2) + 1) = hexa
Else
output(MyPos * 2) = Mid(hexa, 1, 1)
output((MyPos * 2) + 1) = Mid(hexa, 2, 1)
End If
watch2.Stop()
totaltime2 += watch2.ElapsedMilliseconds
totalcalc2 += 1
RaiseEvent Progress(pos)
working2 = False
End While
End Sub
Public Event Progress(ByVal pos As Long)
End Class
J'explique mon problème, en fait mon fichier de sortie semble être bon mais contient des vides 
Si quelqu'un saurait aussi me l'optimiser car j'ai des fichiers de plus en plus conséquents à traiter ...
Merci à tous