diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs index 862f507c6..34102b8cc 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs @@ -280,7 +280,7 @@ public partial class EventService : IEventService public void ClearAllEventSubscribers() where T : class, IEvent { - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); _subscribers.TryRemove(typeof(T), out _); } @@ -329,7 +329,7 @@ public partial class EventService : IEventService public void AddDispatcherEventService(IEventService eventService) { - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); _subscribedEventDispatchers.TryAdd(eventService, eventService); @@ -337,7 +337,7 @@ public partial class EventService : IEventService public void RemoveDispatcherEventService(IEventService eventService) { - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); _subscribedEventDispatchers.TryRemove(eventService, out _);