-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show loading window on different thread and changed it's design
- Loading branch information
Showing
4 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Threading; | ||
|
||
namespace PixiEditor.Views; | ||
|
||
public partial class LoadingWindow : Window | ||
{ | ||
public static LoadingWindow Instance { get; private set; } | ||
|
||
public ImageSource LoadingImage { get; } = new BitmapImage(new Uri("pack://application:,,,/images/processing.gif")); | ||
|
||
public LoadingWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public static void ShowInNewThread() | ||
{ | ||
var thread = new Thread(ThreadStart) { IsBackground = true }; | ||
|
||
thread.SetApartmentState(ApartmentState.STA); | ||
thread.Start(); | ||
} | ||
|
||
public void SafeClose() | ||
{ | ||
Dispatcher.Invoke(Close); | ||
} | ||
|
||
private static void ThreadStart() | ||
{ | ||
Instance = new LoadingWindow(); | ||
Instance.Show(); | ||
|
||
Instance.Closed += (_, _) => | ||
Instance.Dispatcher.InvokeShutdown(); | ||
|
||
Dispatcher.Run(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters