.net - Cancelling background-worker -


i have following problem , hope able me it.

i have worker in vb .net (2010) runs shell-program.

the shell program service , output stuff like:

server initializing... server opening port... more info... 

i able 'catch' output of shell , add textbox (using set text function).

and able cancel worker clicking on stopbutton, when there no more output shell cannot stop worker anymore.

at least suspect that's case.

i've tried checking endofstream (commented section) doesn't work.

i've tried same code test text in stead of 'clsprocess.standardoutput.readline' , works.

so came conclusion must have clsprocess.standardoutput.readline being @ end???

    try         clsprocess.startinfo.useshellexecute = false         clsprocess.startinfo.redirectstandardoutput = true         clsprocess.startinfo.redirectstandarderror = true         clsprocess.startinfo.filename = serverpath + config_executable         clsprocess.startinfo.createnowindow = true         clsprocess.start()     catch ex exception         msgbox(ex.message, msgboxstyle.critical, "error starting server")         debug.print(ex.message)     end try      while not workerserver.cancellationpending         try             'if not clsprocess.standardoutput.endofstream             settext(clsprocess.standardoutput.readline + vbnewline)             'end if         catch ex exception             msgbox(ex.message, msgboxstyle.critical, "error adding line log")         end try          threading.thread.sleep(100)     loop      clsprocess.kill() 

any ideas?

thanks in advance!

regards,

ph

presumably happening on thread. try kill()ing process gui thread instead of setting cancellationpending. correct readline() call blocking, causing while loop never re-evaluate condition once there no more output.

killing process thread should work. (it may throw exception readline(), prepared that.)


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -