943,836 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 842
  • VB.NET RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 21st, 2009
0

Re: Reading info from cli

vb Syntax (Toggle Plain Text)
  1. Dim myprocess As New Process
  2. Dim StartInfo As New System.Diagnostics.ProcessStartInfo
  3. StartInfo.FileName = "mp3hddecoder.exe" 'starts cmd window
  4. StartInfo.Arguments = "-if """ & input & """ -of """ & outputlocation & "wav"""
  5. StartInfo.RedirectStandardInput = True
  6. StartInfo.RedirectStandardOutput = True
  7. StartInfo.RedirectStandardError = True
  8. StartInfo.UseShellExecute = False 'required to redirect
  9. StartInfo.CreateNoWindow = True
  10. myprocess.StartInfo = StartInfo
  11. myprocess.Start()
  12. Dim myThread As New Threading.Thread(AddressOf StartThread)
  13. myThread.Start(myprocess)

here the thread function inclusive the invoking of the labels. you have to invoke the labels when updating controls in a seperate thread. else it will "hang"
vb Syntax (Toggle Plain Text)
  1. Private Sub StartThread(ByVal proc As Object)
  2. Dim myprocess As Process = DirectCast(proc, Process)
  3. Dim SR As System.IO.StreamReader = myprocess.StandardError
  4. Dim SO As System.IO.StreamReader = myprocess.StandardOutput
  5. Do
  6. SR = myprocess.StandardError
  7. SO = myprocess.StandardOutput
  8. Me.Invoke(New labelInvoke(AddressOf updateLabels), Label7, SO.ReadToEnd)
  9. Me.Invoke(New labelInvoke(AddressOf updateLabels), Label5, SR.ReadToEnd)
  10. Loop Until myprocess.HasExited = True
  11. SR.Close()
  12. SO.Close()
  13. End Sub
  14.  
  15. Private Delegate Sub labelInvoke(ByVal lbl As Label, ByVal txt As String)
  16.  
  17. Private Sub updateLabels(ByVal lbl As Label, ByVal txt As String)
  18. lbl.Text = txt
  19. End Sub
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Aug 22nd, 2009
0

Re: Reading info from cli

It isn't hanging anymore, but it isn't displaying anything in the labels and the files become locked.
Last edited by defiant91; Aug 22nd, 2009 at 3:52 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
defiant91 is offline Offline
9 posts
since Aug 2009
Aug 23rd, 2009
0

Re: Reading info from cli

yeah think your Do Loop is not correct. try this :
vb Syntax (Toggle Plain Text)
  1. Private Sub StartThread(ByVal proc As Object)
  2. Dim myprocess As Process = DirectCast(proc, Process)
  3. Dim strLine As String = myprocess.StandardOutput.ReadLine()
  4. Do While strLine.Length > 0
  5. strLine = myprocess.StandardOutput.ReadLine()
  6. Me.Invoke(New labelInvoke(AddressOf updateLabels), Label5, strLine)
  7. Loop
  8. End Sub

this is now only for the standardoutput. the same way you can handle the error output.
the files are locked because you didnt kill the process after converting?
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Aug 23rd, 2009
0

Re: Reading info from cli

That didn't work. Any other ideas?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
defiant91 is offline Offline
9 posts
since Aug 2009
Aug 23rd, 2009
0

Re: Reading info from cli

then you better attach your project so we can take a look into it (if possible with the mp3hddecoder.exe. there is might be another error.
did you even try to debug to see where it fails?
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Telephone Word Generator
Next Thread in VB.NET Forum Timeline: Need Help for my programming





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC