process - C# freeze while starting batch stream -
hey people! working little tool called mineme, , used handle minecraft servers.
so made file stream, should stream output of start_base.cmd (the file starts server). goes wrong, window form freezes, until kill process (java.exe - ran start_base.cmd)
here code:
processstartinfo processinfo = new system.diagnostics.processstartinfo("cmd"); processinfo.windowstyle = processwindowstyle.normal; processinfo.redirectstandardoutput = true; processinfo.redirectstandardinput = true; processinfo.redirectstandarderror = true; processinfo.createnowindow = true; processinfo.useshellexecute = false; process p = new process(); p.startinfo = processinfo; p.start(); textwriter tw = p.standardinput; tw.flush(); tw.writeline("start_base.cmd"); tw.close(); textreader tr = p.standardoutput; string output = tr.readline(); while (output != null) { this.lg_log.items.add(output); // add output string list box output = tr.readline(); }
what's wrong here? :) please me ..
on ui thread start thread process while loop:
thread t = new thread(new threadstart(dowork)); t.start(); public void dowork() { // work done on thread }
Comments
Post a Comment