mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-13 20:30:03 +00:00
implement it thread-safe
This commit is contained in:
@@ -16,6 +16,7 @@ namespace ElectronNET.API
|
||||
public sealed class Menu
|
||||
{
|
||||
private static Menu _menu;
|
||||
private static object _syncRoot = new Object();
|
||||
|
||||
internal Menu() { }
|
||||
|
||||
@@ -25,7 +26,13 @@ namespace ElectronNET.API
|
||||
{
|
||||
if (_menu == null)
|
||||
{
|
||||
_menu = new Menu();
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if(_menu == null)
|
||||
{
|
||||
_menu = new Menu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _menu;
|
||||
|
||||
Reference in New Issue
Block a user