Sistem tepsisi simgesinde çalışan tek bir windows form uygulamasına sahibim. Kullanıcı pencerelerin X düğmesine basarsa, Evet ve Hayır ile bir mesaj kutusu görüntülenir (Evet) -> formu kapatın --- Hayır-> sistem tepsisi simgesinde çalışan formu saklayın). Ben kullanıcı uygulamasını başka bir örneğini açtığınızda ben bu kodu kullanmış böylece çalışan bir örneği zaten varken senaryoyu engellemek için düşünüyordum:Vb.net'de Application.Exit() ve FormClosing olayı
If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length> 1 Then
MessageBox.Show("Another instance is running", "Error Window", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
Application.Exit()
End If
sorun olduğunu ben bu mesajı test etmek istediğinizde görüntülendikten sonra, Tamam'a bastıktan sonra yeni bir mesaj kutusu (Özel Sub Form_FormClosing'den) görünür. NO'yu seçtiğimde, örneğin çalışmam gerekecek! Application.Exit'in Form_FormClosing olayını tetiklediğini okudum.
Form_FormClosing olayının tetiklenmesini iptal etme olasılığı var mı, yoksa yanlış bir şey mi yapıyorum?
'Bu formclosing prosedürü
Private Sub Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
Dim response As MsgBoxResult
response = MsgBox("Are you sure you want to exit", CType(MsgBoxStyle.Question + MsgBoxStyle.YesNo, MsgBoxStyle), "Confirm")
'If the user press Yes the application wil close
'because the application remains in taskmanager after closing i decide to kill the current process
If response = MsgBoxResult.Yes Then
Process.GetCurrentProcess().Kill()
ElseIf response = MsgBoxResult.No Then
e.Cancel = True
Me.WindowState = FormWindowState.Minimized
Me.Hide()
NotifyIcon1.Visible = True
End If
PS: Ben bir programcı böylece benimle sert etmek olmayın lütfen :) durumda
Cevabınız için teşekkürler ... Visual Studio Properties öğesinden ayarları buldum ve bu yöntemi kullanmak için de tamam olmalı ...maalesef benim aplikasyon kapattıktan sonra görev yöneticim kapatmıyor neden yönetmedim ... bu geçici çözüm bulmak neden bu .... Temelde uygulama basit bir windows formudur. – Operagust