Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim f As New Form2 f.Show() End Sub End Class
Public Class Form2 Private Async Sub Form2_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing e.Cancel = True Me.WindowState = FormWindowState.Minimized Me.ShowInTaskbar = False Me.Hide() Await Task.Delay(3000) Me.WindowState = FormWindowState.Normal If My.Application.OpenForms.OfType(Of Form).Contains(Me) Then Debug.WriteLine("ShowInTaskbar = Trueより前 OpenFroms内にあります。") Else Debug.WriteLine("ShowInTaskbar = Trueより前 OpenFroms内にありません。") End If Me.ShowInTaskbar = True Me.Show() If My.Application.OpenForms.OfType(Of Form).Contains(Me) Then Debug.WriteLine("ShowInTaskbar = Trueより後 OpenFroms内にあります。") Else Debug.WriteLine("ShowInTaskbar = Trueより後 OpenFroms内にありません。") End If Debug.WriteLine(My.Application.OpenForms.Count) End Sub End Class