Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27532

VS 2010 [RESOLVED] Trying to exit the program dynamically, but the underlying process continues running

$
0
0
[VS 2010 / Winforms]

Hey guys,

I've got a very simple project that only has 1 form. On form load, I am calling a custom function (in an external module) which checks to see if a specific condition is true (based on user's computer configuration).

If the condition is not true, then I need to exit the program right away. So I am calling MyBase.Close() if the condition is not true.

This successfully closes the GUI part of the program, but the underlying process is still running. And then every time I open/close the program again, it adds a new process (ie if I open and close the program 5 times, then there are 5 separate processes running).

Is there something else I need to call in addition to MyBase.Close() in order to kill everything? I also tried adding MyBase.Dispose() before MyBase.Close(), but that didn't make any difference.

This is my code for the form load...

Code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim Result As Boolean = TestFunction(Result)

        If Result = False Then
            MyBase.Close()
        End If

    End Sub

End Class

My actual code for the custom function is a bit complex, but I made a minimum test case which has the same result (the underlying process never dies)...
Code:

Module Test

    Function TestFunction(ByVal Result As Boolean)

        Dim MsgBx As DialogResult = MessageBox.Show("Test", "Test", MessageBoxButtons.OKCancel)

        If MsgBx = DialogResult.OK Then
            Return True
        Else
            Return False
        End If

    End Function

End Module

If you run the above code, and then click the 'Cancel' button every time the message box pops up, it closes the GUI, but the process continues running in the background.

How can I fix this?

Thanks!

Viewing all articles
Browse latest Browse all 27532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>