| | |
Reading info from cli
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2009
Posts: 271
Reputation:
Solved Threads: 56
vb Syntax (Toggle Plain Text)
Dim myprocess As New Process Dim StartInfo As New System.Diagnostics.ProcessStartInfo StartInfo.FileName = "mp3hddecoder.exe" 'starts cmd window StartInfo.Arguments = "-if """ & input & """ -of """ & outputlocation & "wav""" StartInfo.RedirectStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.RedirectStandardError = True StartInfo.UseShellExecute = False 'required to redirect StartInfo.CreateNoWindow = True myprocess.StartInfo = StartInfo myprocess.Start() Dim myThread As New Threading.Thread(AddressOf StartThread) 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)
Private Sub StartThread(ByVal proc As Object) Dim myprocess As Process = DirectCast(proc, Process) Dim SR As System.IO.StreamReader = myprocess.StandardError Dim SO As System.IO.StreamReader = myprocess.StandardOutput Do SR = myprocess.StandardError SO = myprocess.StandardOutput Me.Invoke(New labelInvoke(AddressOf updateLabels), Label7, SO.ReadToEnd) Me.Invoke(New labelInvoke(AddressOf updateLabels), Label5, SR.ReadToEnd) Loop Until myprocess.HasExited = True SR.Close() SO.Close() End Sub Private Delegate Sub labelInvoke(ByVal lbl As Label, ByVal txt As String) Private Sub updateLabels(ByVal lbl As Label, ByVal txt As String) lbl.Text = txt End Sub
•
•
Join Date: Jun 2009
Posts: 271
Reputation:
Solved Threads: 56
yeah think your Do Loop is not correct. try this :
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?
vb Syntax (Toggle Plain Text)
Private Sub StartThread(ByVal proc As Object) Dim myprocess As Process = DirectCast(proc, Process) Dim strLine As String = myprocess.StandardOutput.ReadLine() Do While strLine.Length > 0 strLine = myprocess.StandardOutput.ReadLine() Me.Invoke(New labelInvoke(AddressOf updateLabels), Label5, strLine) Loop 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?
![]() |
Similar Threads
- Reading Info, Adding Text. [Requests Advice] (C#)
- help me can't boot (*nix Hardware Configuration)
- hi from newbie judych (Getting Started and Choosing a Distro)
- Cms (IT Professionals' Lounge)
- Replace text in a file (Shell Scripting)
- Need help with Binary files and data types in VB6 (Visual Basic 4 / 5 / 6)
- Print 5 records per table row (see script) (Perl)
- Help Reading Info in Text File Into an Array (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Telephone Word Generator
- Next Thread: Need Help for my programming
Views: 580 | Replies: 14
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2005 30minutes 2005 2008 access application arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dll dropdownlist error excel file-dialog folder ftp google hardcopy highlighting image images inline installer listview login mobile ms navigate net networking opacity output peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox serial server soap sorting sql string studio syntax tcp text textbox timer toolbox trim updown usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





