Note that there are some explanatory texts on larger screens.

plurals
  1. POCancelling background-worker
    primarykey
    data
    text
    <p>I have the following problem and I hope someone will be able to help me with it.</p> <p>I have a worker in VB .net (2010) which runs a shell-program.</p> <p>The shell program is a service and output stuff like:</p> <pre><code>Server initializing... Server opening port... more info... </code></pre> <p>I am able to 'catch' the output of the shell and add it to a textbox (using set text function).</p> <p>And I am able to Cancel the worker by clicking on a stopbutton, however when there is no more output by the shell I cannot stop the worker anymore.</p> <p>At least i suspect that's the case.</p> <p>I've tried checking for endofstream (commented section) but that doesn't work.</p> <p>I've also tried to same code with some test text in stead of 'clsProcess.StandardOutput.ReadLine' and that also works.</p> <p>So I came to the conclusion it must have something to do with clsProcess.StandardOutput.ReadLine being at the end???</p> <pre><code> 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 As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Error starting server") Debug.Print(ex.Message) End Try Do While Not workerServer.CancellationPending Try 'If Not clsProcess.StandardOutput.EndOfStream Then SetText(clsProcess.StandardOutput.ReadLine + vbNewLine) 'End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Error adding line to log") End Try Threading.Thread.Sleep(100) Loop clsProcess.Kill() </code></pre> <p>Any ideas?</p> <p>Thanks in advance!</p> <p>Regards,</p> <p>PH</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload