locked
Shut Down Tray Application RRS feed

  • Question

  • I have a multi-threaded tray application. I basically need it to shut down. I do some loops to close down threads, and that does work well. However, if message boxes are open in the UI, this usually prevents shut down. I tried End and Environment.Exit. Thoughts?

    Thursday, May 26, 2011 3:02 PM

Answers

  • Kill it with fire - try this:


     Public Sub killProcess(ByRef strProcessToKill As String)
      Dim proc() As Process = Process.GetProcesses
      For i As Integer = 0 To proc.GetUpperBound(0)
       If proc(i).ProcessName = strProcessToKill Then
        proc(i).Kill()
       End If
      Next
     End Sub
    

    Then use that like so:

    killProcess("YOURPROCESSNAME")
    


    • Proposed as answer by Mike Feng Sunday, May 29, 2011 11:51 AM
    • Marked as answer by Mike Feng Friday, June 3, 2011 3:59 AM
    Thursday, May 26, 2011 3:10 PM