Skip to content

Commit 54d12cc

Browse files
committed
Added the async variable to the WeakEvent constructors.
1 parent a77f800 commit 54d12cc

File tree

11 files changed

+43
-18
lines changed

11 files changed

+43
-18
lines changed

Test/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using ZirconNet.Core.Events;
2+
3+
await Task.Delay(1000);
4+
5+
var test = new WeakEvent<int>();
6+
test.Subscribe((x) => Console.WriteLine($"Hello {x}!"));
7+
test.Publish(1);
8+
9+
await Task.Delay(1000);
10+
11+
Console.ReadLine();
12+
await Task.Delay(1000);

Test/Test.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\src\ZirconNet.Core\ZirconNet.Core.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

ZirconNet.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZirconNet.Console", "src\Zi
1818
EndProject
1919
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZirconNet.Microsoft.DependencyInjection", "src\ZirconNet.Microsoft.DependencyInjection\ZirconNet.Microsoft.DependencyInjection.csproj", "{60BD3E3D-6311-4DE2-81B3-FAC2BEE2C0E8}"
2020
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{803712D0-E7F5-41D7-A036-FBE064290722}"
22+
EndProject
2123
Global
2224
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2325
Debug|Any CPU = Debug|Any CPU
@@ -40,6 +42,10 @@ Global
4042
{60BD3E3D-6311-4DE2-81B3-FAC2BEE2C0E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
4143
{60BD3E3D-6311-4DE2-81B3-FAC2BEE2C0E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
4244
{60BD3E3D-6311-4DE2-81B3-FAC2BEE2C0E8}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{803712D0-E7F5-41D7-A036-FBE064290722}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46+
{803712D0-E7F5-41D7-A036-FBE064290722}.Debug|Any CPU.Build.0 = Debug|Any CPU
47+
{803712D0-E7F5-41D7-A036-FBE064290722}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{803712D0-E7F5-41D7-A036-FBE064290722}.Release|Any CPU.Build.0 = Release|Any CPU
4349
EndGlobalSection
4450
GlobalSection(SolutionProperties) = preSolution
4551
HideSolutionNode = FALSE

src/ZirconNet.Core/Delegates/TryParseHandler.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
33
// </copyright>
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
115
namespace ZirconNet.Core.Delegates;
126

137
/// <summary>

src/ZirconNet.Core/Enums/ApplicationEnvironment.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
33
// </copyright>
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
115
namespace ZirconNet.Core.Enums;
126

137
public enum ApplicationEnvironment

src/ZirconNet.Core/Environments/EnvironmentManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
33
// </copyright>
44

5-
using System.Linq;
65
using ZirconNet.Core.Enums;
76
using ZirconNet.Core.Extensions;
87

src/ZirconNet.Core/Events/WeakEvent.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
33
// </copyright>
44

5-
using System.Runtime.CompilerServices;
6-
75
namespace ZirconNet.Core.Events;
86

97
public sealed class WeakEvent : WeakEventBase<object?>, IWeakEvent
108
{
9+
public WeakEvent(bool isAsync = false)
10+
: base(isAsync)
11+
{
12+
}
13+
1114
public void Subscribe(Action action)
1215
{
1316
SubscribeInternal<Action<object?>>((_) => action());

src/ZirconNet.Core/Events/WeakEventT.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ namespace ZirconNet.Core.Events;
66

77
public sealed class WeakEvent<T> : WeakEventBase<T>, IWeakEvent<T>
88
{
9+
public WeakEvent(bool isAsync = false)
10+
: base(isAsync)
11+
{
12+
}
13+
914
public void Subscribe(Action<T> action)
1015
{
1116
SubscribeInternal(action);

src/ZirconNet.Core/Extensions/RangeExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
33
// </copyright>
44

5-
using System.Runtime.CompilerServices;
65
using ZirconNet.Core.Runtime;
76

87
namespace ZirconNet.Core.Extensions;

src/ZirconNet.Core/Extensions/TaskExtension.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// </copyright>
44

55
using System.Diagnostics;
6-
using System.Net.NetworkInformation;
76

87
namespace ZirconNet.Core.Extensions;
98

0 commit comments

Comments
 (0)