implement it thread-safe

This commit is contained in:
Gregor Biswanger
2017-11-04 00:16:14 +01:00
parent 0ad6358d16
commit 7c13d19e7f
12 changed files with 108 additions and 16 deletions

View File

@@ -201,6 +201,7 @@ namespace ElectronNET.API
// TODO: Implement macOS Events
private static Tray _tray;
private static object _syncRoot = new Object();
internal Tray() { }
@@ -210,7 +211,13 @@ namespace ElectronNET.API
{
if (_tray == null)
{
_tray = new Tray();
lock (_syncRoot)
{
if (_tray == null)
{
_tray = new Tray();
}
}
}
return _tray;