Search Results

Search found 2 results on 1 pages for 'orborde'.

Page 1/1 | 1 

  • .NET Process.Kill() in a safe way

    - by Orborde
    I'm controlling a creaky old FORTRAN simulator from a VB.NET GUI, using redirected I/O to communicate with the simulator executable. The GUI pops up a "status" window with a progress bar, estimated time, and a "STOP" button (Button_Stop). Now, I want the Button_Stop to terminate the simulator process immediately. The obvious way to do this is to call Kill() on the Child Process object. This gives an exception if it's done after the process has exited, but I can test whether the process is exited before trying to kill it, right? OK, so I do the following when the button is clicked: If Not Child.HasExited Then Child.Kill() Button_Stop.Enabled = False End If However, what if the process happens to exit between the test and the call to Kill()? In that case, I get an exception. The next thing to occur to me was that I can do Button_Stop.Enabled = False in the Process.Exited event handler, and thus prevent the Child.Kill() call in the Button_Stop.Clicked handler. But since the Process.Exited handler is called on a different thread, that still leaves the following possible interleaving: Child process exits. Process.Exited fires, calls Invoke to schedule the Button_Stop.Enabled = False User clicks on Button_Stop, triggering Child.Kill() Button_Stop.Enabled = False actually happens. An exception would then be thrown on step 3. How do I kill the process without any race conditions? Am I thinking about this entirely wrong?

    Read the article

  • How to retarget the scroll wheel in VB.Net?

    - by Orborde
    I have a form in VB.Net with Autoscroll enabled and several ComboBoxes within it. When I click on a ComboBox, I can use the mouse wheel to scroll through options, but I cannot deselect the ComboBox (by clicking off it on a blank portion of the parent form) in order to return to scrolling the parent form. This makes navigation in the form annoying, as I instinctively click off the control and flip the scroll wheel, causing the ComboBox to change selections instead of moving the parent form. Is there a way to make this work in the intuitive way I expect it to, or do I have some conceptual confusion that makes this the wrong question to ask?

    Read the article

1