Reputation:
I have opened childwindow from parentWindow (non-modal) - what's the best approach to achieving a 'wait' so that parentWindow will know when childWindow has closed? For a couple of reasons I cannot use showDialog(). I have tried a while loop (testing the childWindow's visibility property) but it just breaks (no exception - but just doesn't open childWindow). Is it a case of multi-threading??
Upvotes: 1
Views: 2865
Reputation: 48975
what's the best approach to achieving a 'wait' so that parentWindow will know when childWindow has closed?
You could use events so the parent window is notified when the child window closes. For instance, there is the Closed event.
Window childWindow = new ....
childWindow.Closed += (sender, e) =>
{
// Put logic here
// Will be called after the child window is closed
};
childWindow.Show();
Upvotes: 5
Reputation: 57573
I think you can use this:
public ShowChild()
{
childWindow child = new childWindow();
child.Closed += new EventHandler(child_Closed);
child.Show();
}
void child_Closed(object sender, EventArgs e)
{
// Child window closed
}
Upvotes: 1