Skip to content

refactor: use System.Threading.Lock for the remaining monitor locks#851

Merged
laurentiu021 merged 1 commit into
mainfrom
refactor/r8-system-threading-lock
Jun 11, 2026
Merged

refactor: use System.Threading.Lock for the remaining monitor locks#851
laurentiu021 merged 1 commit into
mainfrom
refactor/r8-system-threading-lock

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Summary

Completes the System.Threading.Lock migration. ActivityLogService was already
converted; this brings the remaining six monitor locks to the same idiom. No
behavior change — lock(Lock) lowers to EnterScope()/Dispose(), identical
mutual exclusion to a lock(object) monitor.

Changes

private readonly object _x = new()private readonly Lock _x = new() in:

  • Services/AppAlertService.cs_watcherLock
  • Services/IconExtractorService.cs_evictionLock (static)
  • Services/PingMonitorService.cs_stateLock
  • Services/SystemInfoService.cs_cacheLock
  • Services/TracerouteMonitorService.cs_stateLock
  • ViewModels/ConsoleViewModel.cs_gate

Why Lock

The dedicated lock type makes "this field exists only to be locked on" explicit at
the type level, lets the analyzer flag accidental Monitor/Wait/Pulse misuse,
and uses the lighter EnterScope lock path. System.Threading is already in the
project's implicit usings, so no using change is needed.

Verification

  • Every field verified to be used only as a lock() target — no Monitor.Wait/Pulse,
    not passed as an argument, not locked from outside the declaring type.
  • Build: main + Tests + IntegrationTests all 0 warnings / 0 errors.
  • The 13 lock() statement sites compile unchanged against the new type.

Behavior identical (Protocol Q). refactor: → no release.

@laurentiu021 laurentiu021 merged commit 63e87af into main Jun 11, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the refactor/r8-system-threading-lock branch June 11, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant