From 95c28747d77a90b9dff5c4188f691c0692b540cd Mon Sep 17 00:00:00 2001
From: Dusty <21290407+TheDusty01@users.noreply.github.com>
Date: Sat, 3 Dec 2022 17:49:08 +0100
Subject: [PATCH] Refactored the library and upgraded to .NET Standard 2.1
* Removed the requirement to inherit your event classes from AsyncEventArgs
* Structs can now be used for event args
* Added AsyncEventHandlers without event args
* Updated samples
---
.../AsyncEventHandlers.Benchmarks.csproj | 2 +-
AsyncEventHandlers.Benchmarks/Program.cs | 56 ++--
AsyncEventHandlers/AsyncEvent.cs | 29 ++
AsyncEventHandlers/AsyncEventArgs.cs | 26 +-
AsyncEventHandlers/AsyncEventHandler.cs | 270 ++++++++++--------
.../AsyncEventHandlerDelegate.cs | 24 +-
AsyncEventHandlers/AsyncEventHandlers.csproj | 8 +-
AsyncEventHandlers/WeakAsyncEventHandler.cs | 135 +++++++++
README.md | 26 +-
...AsyncEventHandlers.Samples.Delegate.csproj | 2 +-
Samples/Delegate/FakeWebsocketServer.cs | 77 +++--
Samples/Delegate/Program.cs | 73 +++--
.../AsyncEventHandlers.Samples.Type.csproj | 2 +-
Samples/Type/FakeWebsocketServer.cs | 81 +++---
Samples/Type/Program.cs | 92 +++---
15 files changed, 545 insertions(+), 358 deletions(-)
create mode 100644 AsyncEventHandlers/AsyncEvent.cs
create mode 100644 AsyncEventHandlers/WeakAsyncEventHandler.cs
diff --git a/AsyncEventHandlers.Benchmarks/AsyncEventHandlers.Benchmarks.csproj b/AsyncEventHandlers.Benchmarks/AsyncEventHandlers.Benchmarks.csproj
index dd92046..dbf8090 100644
--- a/AsyncEventHandlers.Benchmarks/AsyncEventHandlers.Benchmarks.csproj
+++ b/AsyncEventHandlers.Benchmarks/AsyncEventHandlers.Benchmarks.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0
+ net7.0
enable
enable
diff --git a/AsyncEventHandlers.Benchmarks/Program.cs b/AsyncEventHandlers.Benchmarks/Program.cs
index a9790a1..365aa3d 100644
--- a/AsyncEventHandlers.Benchmarks/Program.cs
+++ b/AsyncEventHandlers.Benchmarks/Program.cs
@@ -11,24 +11,36 @@ public static void Main()
BenchmarkRunner.Run();
}
- private static AsyncEventHandler Struct_AsyncEventHandler = new AsyncEventHandler();
- private static event AsyncEventHandlerDelegate Delegate_AsyncEventHandler;
+ private static AsyncEventHandler Struct_AsyncEventHandler = new AsyncEventHandler();
+ private static WeakAsyncEventHandler WeakAsyncEventHandler = new WeakAsyncEventHandler();
+ private static event AsyncEventHandlerDelegate Delegate_AsyncEventHandler;
+
+ private readonly List