mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-22 15:04:47 +00:00
implement it thread-safe
This commit is contained in:
@@ -14,6 +14,7 @@ namespace ElectronNET.API
|
||||
public sealed class IpcMain
|
||||
{
|
||||
private static IpcMain _ipcMain;
|
||||
private static object _syncRoot = new Object();
|
||||
|
||||
internal IpcMain() { }
|
||||
|
||||
@@ -23,7 +24,13 @@ namespace ElectronNET.API
|
||||
{
|
||||
if(_ipcMain == null)
|
||||
{
|
||||
_ipcMain = new IpcMain();
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if(_ipcMain == null)
|
||||
{
|
||||
_ipcMain = new IpcMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _ipcMain;
|
||||
|
||||
Reference in New Issue
Block a user