-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
bff66c9
commit 95c2874
Showing
15 changed files
with
545 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
namespace AsyncEventHandlers; | ||
|
||
/// <summary> | ||
/// The "action" delegate which should be supplied to the | ||
/// <see cref="AsyncEventHandler{TEventData}.Register(AsyncEvent{TEventData})"/> and <see cref="AsyncEventHandler{TEventData}.Unregister(AsyncEvent{TEventData})"/> | ||
/// methods. | ||
/// <para/> | ||
/// This shouldn't be used with the <see langword="event"/> keyword. | ||
/// </summary> | ||
/// <typeparam name="TEventData">Event data to pass to each subscriber.</typeparam> | ||
/// <param name="data">An object that contains the event data.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to communicate cancellation of the async operation.</param> | ||
/// <returns></returns> | ||
public delegate Task AsyncEvent<in TEventData>(TEventData data, CancellationToken cancellationToken); | ||
|
||
/// <summary> | ||
/// The "action" delegate which should be supplied to the | ||
/// <see cref="AsyncEventHandler.Register(AsyncEvent)"/> and <see cref="AsyncEventHandler.Unregister(AsyncEvent)"/> | ||
/// methods. | ||
/// <para/> | ||
/// This shouldn't be used with the <see langword="event"/> keyword. | ||
/// </summary> | ||
/// <typeparam name="TEventData">Event data to pass to each subscriber.</typeparam> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to communicate cancellation of the async operation.</param> | ||
/// <returns></returns> | ||
public delegate Task AsyncEvent(CancellationToken cancellationToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading; | ||
|
||
namespace AsyncEventHandlers | ||
namespace AsyncEventHandlers; | ||
|
||
/// <summary> | ||
/// The <see cref="CancellationToken"/> is automatically set. | ||
/// </summary> | ||
public interface IAsyncEventArgs | ||
{ | ||
/// <summary> | ||
/// The <see cref="CancellationToken"/> is automatically set. | ||
/// </summary> | ||
public class AsyncEventArgs : EventArgs | ||
{ | ||
public CancellationToken CancellationToken { get; internal set; } | ||
} | ||
CancellationToken CancellationToken { get; internal set; } | ||
} | ||
|
||
/// <inheritdoc cref="IAsyncEventArgs" /> | ||
public class AsyncEventArgs : IAsyncEventArgs | ||
{ | ||
public CancellationToken CancellationToken { get; set; } | ||
} |
Oops, something went wrong.