Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ AsyncHelper.RunSync(() => SomeFunctionAsync(param1, param2));

// Basic usage for an action running Task<T> or ValueTask<T>
var result = AsyncHelper.RunSync(() => SomeFunctionAsync(param1, param2));

// Pass in state as a parameter to reduce heap allocations due to closures
AsyncHelper.RunSync(state => SomeFunctionAsync(state, true), param1);
// or you can use a method group if parameters align precisely
AsyncHelper.RunSync(SomeFunctionAsyncWithOneParameter, param1);
```

## Background
Expand Down Expand Up @@ -66,8 +71,8 @@ best approach.
cd src/CenterEdge.Async.Benchmarks

# x64
dotnet run -c Release -f net5.0 -- job default --runtimes net48 netcoreapp31 netcoreapp50
dotnet run -c Release -f net8.0 -- job default --runtimes net48 net6.0 net8.0

# x86, .NET 4.8 only
dotnet run -c Release -f net5.0 -- job default --runtimes net48 --platform x86
dotnet run -c Release -f net8.0 -- job default --runtimes net48 --platform x86
```
14 changes: 13 additions & 1 deletion src/CenterEdge.Async/CenterEdge.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<Copyright>Copyright 2023 CenterEdge Software and original post authors at https://social.msdn.microsoft.com/Forums/en-US/163ef755-ff7b-4ea5-b226-bbe8ef5f4796/is-there-a-pattern-for-calling-an-async-method-synchronously?forum=async</Copyright>
<Authors>CenterEdge Software,Brant Burnett</Authors>
<Description>Assists in the (risky) process of blocking a synchronous method waiting for an asynchronous Task to complete.</Description>
<PackageTags>async threadpool deadlocks</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Binary file added src/CenterEdge.Async/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.