Skip to content

Commit

Permalink
Use .NET 9 Lock via PolyShim
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Sep 6, 2024
1 parent 2a8773a commit f1e8d39
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Onova.Updater/Onova.Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="CSharpier.MsBuild" Version="0.29.1" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.12.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.13.0" PrivateAssets="all" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Onova/Onova.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Deorcify" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.12.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.13.0" PrivateAssets="all" />
<PackageReference Include="System.Text.Json" Version="8.0.4" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.0'))" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Onova/Utils/ProgressMixer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace Onova.Utils;

internal class ProgressMixer
{
private readonly Lock _lock = new();
private readonly IProgress<double> _output;
private readonly Dictionary<int, double> _splitTotals;

Expand All @@ -22,7 +24,7 @@ public IProgress<double> Split(double multiplier)
var index = _splitCount++;
return new Progress<double>(p =>
{
lock (_splitTotals)
using (_lock.EnterScope())
{
_splitTotals[index] = multiplier * p;
_output.Report(_splitTotals.Values.Sum());
Expand Down

0 comments on commit f1e8d39

Please sign in to comment.