Main screen opens a dialog window (win) upon button click.
Private Sub myBtn_click(sender As Object, e As RoutedEventArgs) Handles myBtn.Click
Dim w As New win
w.Owner = Me
Dim d As DataRowView
If w.ShowDialog = True Then
w = Nothing
d = Nothing
Win opens and does stuff with two datasets it creates. Win's WindowStyle was a SingleBorderWindow. So it had the standard tools in the upper right for maximizing, minimizing, and closing.
It has a button for Save and Cancel.
Clicking Save and Cancel seem to work fine.
However, when I close win using the standard window close tool in the upper left, SOMETIMES it would work fine and other times win's would turn BLACK and would just hang there until I minimized it. The calling window went back to do its thing.
If I make win's WindowStyle None then the user has no standard window close tool to make this annoyance. But that's crazy.
It must be that I'm not closing the window and releasing the resources properly, with Garbage Collection or Mr. Disposal getting in the way.
How can I make it work properly?
Here's code for win. Thanks
Public Class win
Private ds1 As New DataSet
Private ds2 As New DataSet
Private Sub btnSave_Click(sender As Object, e As RoutedEventArgs) Handles btnSave.Click
Me.DialogResult = True
Private Sub btnCancel_Click(sender As Object, e As RoutedEventArgs) Handles btnCancel.Click
Private Sub CancelMe()
Me.DialogResult = False
Private Sub win_Closing(sender As Object, e As ComponentModel.CancelEventArgs) Handles Me.Closing
ds1 = Nothing
ds2 = Nothing