vb.net - vb (output is doubling in Richtextbox field) -
using vb in visual studio 2012. can't figure out how clear whatever need clear.
see code i'm using below:
private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click if richtextbox1.text > "" pingproc.canceloutputread() 'need clearing code here richtextbox1.text = "" end if me.height = 522 pingproc.startinfo .filename = "cmd.exe" .arguments = "/c c:\tracert.bat" .redirectstandardinput = true .redirectstandardoutput = true .useshellexecute = false .createnowindow = true end addhandler pingproc.outputdatareceived, addressof handleprocessoutput pingproc.start() pingproc.beginoutputreadline() end sub private sub handleprocessoutput(byval sender object, byval e system.diagnostics.datareceivedeventargs) me.invoke(new delegateaddtext(addressof addtext), new object() {e.data}) end sub delegate sub delegateaddtext(byval text string) private sub addtext(byval text string) richtextbox1.text &= text & vbcrlf end sub
now when run code, runs fine. have run second time or more. when end double or more copies depending how many times run code.
first run:
performing trace route 198.224.169.244 tracing route 244.sub-198-224-169.myvzw.com [198.224.169.244] on maximum of 30 hops:
second run:
performing trace route 198.224.169.244 performing trace route 198.224.169.244 tracing route 244.sub-198-224-169.myvzw.com [198.224.169.244] tracing route 244.sub-198-224-169.myvzw.com [198.224.169.244] on maximum of 30 hops: on maximum of 30 hops:
might caused addhandler
... so, can try ..
dim handled boolean if not handled addhandler pingproc.outputdatareceived, addressof handleprocessoutput handled = true end if
Comments
Post a Comment