[trivial] `EventAwaiter(s)`: Fix IDE0130 warnings
MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
@@ -7,6 +7,7 @@ using WalletWasabi.BitcoinCore;
using WalletWasabi.Blockchain.Blocks;
using WalletWasabi.Blockchain.Mempool;
using WalletWasabi.Blockchain.Transactions;
+using WalletWasabi.Helpers;
using WalletWasabi.Services;
using WalletWasabi.Stores;
using WalletWasabi.Tests.Helpers;

MODIFY
WalletWasabi.Tests/UnitTests/BlockNotifierTests.cs
WalletWasabi.Tests/UnitTests/BlockNotifierTests.cs
@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using NBitcoin;
using WalletWasabi.Blockchain.Blocks;
+using WalletWasabi.Helpers;
using Xunit;
namespace WalletWasabi.Tests.UnitTests;

MODIFY
WalletWasabi/Bases/PeriodicRunner.cs
WalletWasabi/Bases/PeriodicRunner.cs
@@ -2,6 +2,7 @@ using Microsoft.Extensions.Hosting;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Extensions;
+using WalletWasabi.Helpers;
using WalletWasabi.Logging;
namespace WalletWasabi.Bases;

MODIFY
WalletWasabi/Helpers/EventAwaiter.cs
WalletWasabi/Helpers/EventAwaiter.cs
@@ -2,7 +2,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-namespace System;
+namespace WalletWasabi.Helpers;
/// <summary>
/// Source: https://stackoverflow.com/a/42117130/2061103

MODIFY
WalletWasabi/Helpers/EventsAwaiter.cs
WalletWasabi/Helpers/EventsAwaiter.cs
@@ -2,9 +2,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using WalletWasabi.Helpers;
-namespace System;
+namespace WalletWasabi.Helpers;
/// <summary>
/// Source: https://stackoverflow.com/a/42117130/2061103
@@ -14,12 +13,13 @@ public class EventsAwaiter<TEventArgs>
public EventsAwaiter(Action<EventHandler<TEventArgs>> subscribe, Action<EventHandler<TEventArgs>> unsubscribe, int count)
{
Guard.MinimumAndNotNull(nameof(count), count, 0);
- Lock = new object();
+
var eventsArrived = new List<TaskCompletionSource<TEventArgs>>(count);
for (int i = 0; i < count; i++)
{
eventsArrived.Add(new TaskCompletionSource<TEventArgs>());
}
+
EventsArrived = eventsArrived;
subscribe(Subscription);
Unsubscribe = unsubscribe;
@@ -28,7 +28,7 @@ public class EventsAwaiter<TEventArgs>
protected IEnumerable<TaskCompletionSource<TEventArgs>> EventsArrived { get; }
private Action<EventHandler<TEventArgs>> Unsubscribe { get; }
- private object Lock { get; }
+ private object Lock { get; } = new();
protected IEnumerable<Task<TEventArgs>> Tasks => EventsArrived.Select(x => x.Task);

[trivial] `EventAwaiter(s)`: Fix IDE0130 warnings (#9580)