Hi,

I have a windows application. I would like to run a statement while exiting my application. I tried adding my statement on FormClosing event. but it only executes if the application is closed properly. However, If the application is closed via task manager or system is restarted or logged out, etc. then the statement in closing or disposed event is not getting executed.

Code:
Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        MsgBox("disposed")
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
        MsgBox("closing")
    End Sub
can some one tell me how to get my statement executed even the user tries to log out or shut down or application is closed via task manger.

Thanks