Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

fix(infra,boot): prevent multithreading issues by locking command invocations

Larsd73150d71505
diff --git a/LarsWM.Bootstrapper/Startup.cs b/LarsWM.Bootstrapper/Startup.cs
index bc3896c2..5a9ff064 100644
--- a/LarsWM.Bootstrapper/Startup.cs
+++ b/LarsWM.Bootstrapper/Startup.cs
@@ -40,13 +40,13 @@ namespace LarsWM.Bootstrapper
public void Init()
{
+ // Populate initial monitors, windows, workspaces and user config.
+ PopulateInitialState();
+
_keybindingService.Init();
_windowEventService.Init();
_windowHooksHandler.Configure();
-
- // Populate initial monitors, windows, workspaces and user config.
- PopulateInitialState();
}
/// <summary>
diff --git a/LarsWM.Infrastructure/Bussing/Bus.cs b/LarsWM.Infrastructure/Bussing/Bus.cs
index 9fa64099..dc9026f5 100644
--- a/LarsWM.Infrastructure/Bussing/Bus.cs
+++ b/LarsWM.Infrastructure/Bussing/Bus.cs
@@ -13,6 +13,7 @@ namespace LarsWM.Infrastructure.Bussing
{
private List<Type> _registeredCommandHandlers = new List<Type>();
private List<Type> _registeredEventHandlers = new List<Type>();
+ private static readonly Object lockObj = new Object();
/// <summary>
/// Sends command to appropriate command handler.
@@ -36,7 +37,10 @@ namespace LarsWM.Infrastructure.Bussing
Debug.WriteLine($"Command {command.Name} invoked.");
ICommandHandler<T> handlerInstance = ServiceLocator.Provider.GetRequiredService(handlers[0]) as ICommandHandler<T>;
- return handlerInstance.Handle(command);
+ lock (lockObj)
+ {
+ return handlerInstance.Handle(command);
+ }
}
/// <summary>