Search code examples
c#wpfmessage

Showing Message for loading WPF


I have a WPF application that connects and disconnects to WiFi.
It takes around 2 seconds to complete the process. During that time, I want to show a simple waiting message on the top of my current window "Connecting.." or "Disconnecting...", which closes as soon is the process is complete.

What should I use?

MessageBox is not working because a) it has a button, and b) I can't just close it at my own will through code (I think).


Solution

  • When the Wi-Fi starts to connect, use:

    MyWindow popup = new MyWindow();
    popup.ShowDialog();
    

    Where MyWindow is a small form containing information.

    And when the Wi-Fi is connected, use:

    popup.Close();
    

    ShowDialog() prevents user interaction with the parent form.