none
How to solve, When the user click on close the process still running? RRS feed

  • Question

  • Dears,

    i have created a project with DB connection , when the user click on (X) to close the application , it will be closed but the process still under the process list 

    is there a code need to be added in order to close everything once the user click on (X) ??

    Wednesday, June 19, 2019 6:41 AM

Answers

  • Hi,

    When closing a form, the process will not end as long as there is a thread still working,try the  code:

    Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
            System.Environment.Exit(0)
        End Sub
    or
     Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
            System.Environment.Exit(0)
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Raad Daqqah Wednesday, June 19, 2019 7:23 AM
    Wednesday, June 19, 2019 7:05 AM

All replies

  • Hi,

    When closing a form, the process will not end as long as there is a thread still working,try the  code:

    Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
            System.Environment.Exit(0)
        End Sub
    or
     Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
            System.Environment.Exit(0)
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Raad Daqqah Wednesday, June 19, 2019 7:23 AM
    Wednesday, June 19, 2019 7:05 AM
  • Thank you very much

    it's solved =D

    Wednesday, June 19, 2019 7:23 AM