Skip to content

Commit 1279890

Browse files
committed
refactor: update Lock usage
1 parent c28efcb commit 1279890

File tree

7 files changed

+7
-6
lines changed

7 files changed

+7
-6
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<LangVersion>Preview</LangVersion>
2727
</PropertyGroup>
2828
<ItemGroup>
29+
<Using Include="System.Object" Alias="Lock" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" />
2930
<None Include="README.md" Pack="true" PackagePath="\" />
3031
<None Include="$([MSBuild]::GetPathOfFileAbove('icon.jpg', '$(MSBuildThisFileDirectory)../'))" Pack="true" Visible="false" PackagePath=""/>
3132
</ItemGroup>

src/WeihanLi.Common.Logging.Serilog/SerilogHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace WeihanLi.Common.Logging.Serilog;
44

55
public static class SerilogHelper
66
{
7-
private static readonly object Locker = new();
7+
private static readonly Lock Locker = new();
88

99
public static void LogInit(Action<LoggerConfiguration> configureAction)
1010
{

src/WeihanLi.Common/Aspect/ProxyUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static class ProxyUtils
1717
private static readonly Dictionary<string, Type> _proxyTypes = [];
1818

1919
private const string TargetFieldName = "__target";
20-
private static readonly object _typeLock = new();
20+
private static readonly Lock _typeLock = new();
2121

2222
private static readonly Func<Type, Type?, string> _proxyTypeNameResolver;
2323

src/WeihanLi.Common/DependencyResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace WeihanLi.Common;
99
/// </summary>
1010
public static class DependencyResolver
1111
{
12-
private static readonly object _lock = new();
12+
private static readonly Lock _lock = new();
1313
public static IDependencyResolver Current { get; private set; } = new DefaultDependencyResolver();
1414

1515
public static TService? ResolveService<TService>() => Current.ResolveService<TService>();

src/WeihanLi.Common/Helpers/InvokeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static async Task<double> ProfileAsync<T1, T2, T3>(Func<T1, T2, T3, Task>
9696

9797
public static Action<Exception>? OnInvokeException { get; set; }
9898

99-
private static readonly object _exitLock = new();
99+
private static readonly Lock _exitLock = new();
100100
private static volatile bool _exited;
101101
private static readonly Lazy<CancellationTokenSource> LazyCancellationTokenSource = new();
102102
private static void InvokeExitHandler(object? sender, EventArgs? args)

src/WeihanLi.Common/Helpers/PeriodBatching/PeriodicBatching.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public abstract class PeriodicBatching<TEvent> : IDisposable where TEvent : clas
3232
private readonly BoundedConcurrentQueue<TEvent> _queue;
3333
private readonly BatchedConnectionStatus _status;
3434
private readonly Queue<TEvent> _waitingBatch = new();
35-
private readonly object _stateLock = new();
35+
private readonly Lock _stateLock = new();
3636
private readonly PortableTimer _timer;
3737
private bool _unloading;
3838
private bool _started;

src/WeihanLi.Common/Helpers/PeriodBatching/PortableTimer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace WeihanLi.Common.Helpers.PeriodBatching;
1818

1919
internal sealed class PortableTimer : IDisposable
2020
{
21-
private readonly object _stateLock = new();
21+
private readonly Lock _stateLock = new();
2222
private readonly Func<CancellationToken, Task> _onTick;
2323
private readonly CancellationTokenSource _cancel = new();
2424
private readonly Timer _timer;

0 commit comments

Comments
 (0)