Search code examples
c#wpfuser-interfacewindowfreeze

Open a second window while method is running - WPF


I want to open a new Window, while a method of mine is running, to show that something is being done in the background.

// Open second window
Encoder.Encode(imgSource, chooseDestination.Text);
// Close second window

EDIT: I want the new window to be shown at all times as long as the methode is running, because the program should only continue when the method is finished. I only want the new window to appear to show the User that somthing is being done in the background (for example have a progress Bar appear on the new window)


Solution

  • Maybe you should consider using asynchronous programming. This is helpful when you don't want to freeze application components (such as UI) while the application is doing certain tasks.

    Asynchronous programming