samedi 18 avril 2015

Help with command line Background Process on Vb.Net

Hello friends.



I've just started a very simple project on Vb.Net

It is a software for send commands to Android devices trhough Android Data Bridge (ADB).



The problem is that every time I send a command my software stucksn then I have to run the Task Manager and finish the process manually. After that, my software shows the information gotten from ADB.



This is very annoying.



So, I thing that it could be solved if I sedn and recive information from ADB trough background process.



Aoreciate any help or guide.



This is the code for send and recive:




Quote:








Public Sub Execute_command(ByVal Argumentos As String)

Try

RichTextBox3.Clear()

Dim p As New Process()

With p.StartInfo

.UseShellExecute = False

.WindowStyle = ProcessWindowStyle.Hidden

.RedirectStandardOutput = True

.RedirectStandardError = True

.CreateNoWindow = True

.FileName = AppDomain.CurrentDomain.BaseDirectory & "ADB/adb.exe"

.Arguments = Argumentos

End With



p.Start()

Do While Not p.StandardOutput.EndOfStream

RichTextBox3.Text = RichTextBox3.Text &(p.StandardOutput.ReadLine) & vbNewLine

RichTextBox3.ScrollToCaret()

Loop



Application.DoEvents()



RichTextBox3.Text = RichTextBox3.Text & p.StandardError.ReadToEnd

RichTextBox3.Text = RichTextBox3.Text & vbNewLine

RichTextBox3.ScrollToCaret()



p.Dispose()





Catch ex As Exception

MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End Sub







Br,

Josedavido





via Welcome to gsm-tips http://ift.tt/1DVn3Ry

Aucun commentaire:

Enregistrer un commentaire