Reading info from cli

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2009
Posts: 271
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 56
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Reading info from cli

 
0
  #11
Aug 21st, 2009
  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"
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 9
Reputation: defiant91 is an unknown quantity at this point 
Solved Threads: 0
defiant91 defiant91 is offline Offline
Newbie Poster

Re: Reading info from cli

 
0
  #12
Aug 22nd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 271
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 56
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Reading info from cli

 
0
  #13
Aug 23rd, 2009
yeah think your Do Loop is not correct. try this :
  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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 9
Reputation: defiant91 is an unknown quantity at this point 
Solved Threads: 0
defiant91 defiant91 is offline Offline
Newbie Poster

Re: Reading info from cli

 
0
  #14
Aug 23rd, 2009
That didn't work. Any other ideas?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 271
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 56
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Reading info from cli

 
0
  #15
Aug 23rd, 2009
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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum


Views: 580 | Replies: 14
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC