mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-08-13 11:39:52 +00:00
implement it thread-safe
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user