IAsyncDisposable Change

- removed own implementation, using BCL library version now
This commit is contained in:
Brett Hewitson 2022-06-22 01:14:08 +10:00
parent 7688e2b2ae
commit db30824957
12 changed files with 89 additions and 138 deletions

View file

@ -1,9 +0,0 @@
using System.Threading.Tasks;
namespace ServerManagerTool.Common.Interfaces
{
public interface IAsyncDisposable
{
Task DisposeAsync();
}
}

View file

@ -1,5 +1,4 @@
using ServerManagerTool.Common.Interfaces;
using System;
using System;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
@ -44,7 +43,7 @@ namespace ServerManagerTool.Common.Lib
return PostAction(() => { action.Invoke(); return true; });
}
public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await PostAction(() => this.workQueue.Complete());
}

View file

@ -17,9 +17,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="5.0.1" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="WindowsFirewallHelper" Version="2.2.0.86" />

View file

@ -12,6 +12,11 @@ namespace ServerManagerTool.Common.Utils
// Do nothing, let the task continue. Eliminates compiler warning about non-awaited tasks in an async method.
}
public static void DoNotWait(this ValueTask task)
{
// Do nothing, let the task continue. Eliminates compiler warning about non-awaited tasks in an async method.
}
public static async Task RunOnUIThreadAsync(Action action)
{
var app = Application.Current;