-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure the Setup of the AppBuilder is only done once.
- Loading branch information
Showing
3 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
tests/Magick.NET.AvaloniaMediaImaging.Tests/AppBuilderHelper.cs
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System.Threading; | ||
using Avalonia; | ||
|
||
namespace Magick.NET.AvaloniaMediaImaging.Tests | ||
{ | ||
internal static class AppBuilderHelper | ||
{ | ||
private static readonly SemaphoreSlim _lock = new(1); | ||
private static bool _setupDone; | ||
|
||
public static void Setup() | ||
{ | ||
if (_setupDone) | ||
return; | ||
|
||
_lock.Wait(); | ||
|
||
try | ||
{ | ||
|
||
if (_setupDone) | ||
return; | ||
|
||
_setupDone = true; | ||
|
||
AppBuilder | ||
.Configure<Application>() | ||
.UsePlatformDetect() | ||
.SetupWithoutStarting(); | ||
} | ||
finally | ||
{ | ||
_lock.Release(); | ||
} | ||
} | ||
} | ||
} |
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