hi all, just got another problem in my application :(, its a client-server application, where i want to disable the user from closing the application in the main window. I'm using VS.NET 2003 environment, the codes:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.Canc
elEventArg
s) Handles MyBase.Closing
Dim formStackTrace As System.Diagnostics.StackTr
ace = New System.Diagnostics.StackTr
ace(True)
Dim formStackFrame As System.Diagnostics.StackFr
ame
formStackFrame = formStackTrace.GetFrame(7)
Select Case formStackFrame.GetMethod.N
ame.ToStri
ng
Case "CallWindowProc"
e.Cancel = True
NotifyIcon1.Visible = True
Me.Hide()
Case Else
If connectionProblem Then
Exit Sub
Else
Try
SendData("LOGON|" + computerName + "|" + hostName + "|Logoff|" + Today() + "," + TimeOfDay() + "|" + hostIP + "|")
Catch ex As Exception
MsgBox("Sending of logon data has been failed.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Critical)
End Try
End If
End Select
End Sub
by using the code above, i can stop the user from closing the main window, but now the problem is the client side is unable to one last data back to the server. when i try to shutdown the window, window is unable to stop the application as well, except i stop it in the task manager and by end it tat way the client will able to send the data back to server before it is closed. is the there any way i can know tat the windows is shutting so that i can allow the application to exit and send the data back to server? or is there any other case in System.Diagnostics.StackTr
ace can check that the application closing is denoted by the windows station? but since i already put the case else in my code then it should be work as expected, except there is no such case that application closing is denoted by windows station. Any ideas?
Start Free Trial