Reputation:
I have tried around with threads a little bit but I can't figure out the right way to get what I want (because I'm not very familiar with threads). I have a "Sign out" button in my main form. When clicked then the Form shuts completely down and restarts (Application.Restart()). Now I wanted another form pop up when the main form gets closed (Just a label with "Loging out - Please wait"). When the main form opens then this "Log out form" should disappear. I know I should make the Sign out form as foreground thread but how do I call the Form.Open() method with the thread and how I can get it closed when the main form starts?
Upvotes: 0
Views: 95
Reputation: 711
Try to show the second form in the FormClosing event of the main form.
When the main form closes it most certainly "shuts down" the message loop of the application making it impossible to spawn any new window or closing any window that is already open.
Edit: As of the comments: Showing the logout form from the process that is about to Restart until the new process has been started successfully will not be possible because the old process will be shut down and therefore any open form it shows.
Possible solutions:
Upvotes: 1