mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
use EmptyResult instead of custom NoResponse
This commit is contained in:
@@ -217,15 +217,7 @@ namespace BTCPayServer.Controllers
|
|||||||
leases.Dispose();
|
leases.Dispose();
|
||||||
await CloseSocket(webSocket);
|
await CloseSocket(webSocket);
|
||||||
}
|
}
|
||||||
return new NoResponse();
|
return new EmptyResult();
|
||||||
}
|
|
||||||
|
|
||||||
class NoResponse : IActionResult
|
|
||||||
{
|
|
||||||
public Task ExecuteResultAsync(ActionContext context)
|
|
||||||
{
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArraySegment<Byte> DummyBuffer = new ArraySegment<Byte>(new Byte[1]);
|
ArraySegment<Byte> DummyBuffer = new ArraySegment<Byte>(new Byte[1]);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Logging;
|
using BTCPayServer.Logging;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace BTCPayServer
|
namespace BTCPayServer
|
||||||
{
|
{
|
||||||
@@ -26,8 +27,12 @@ namespace BTCPayServer
|
|||||||
|
|
||||||
public Action<Object> Act { get; set; }
|
public Action<Object> Act { get; set; }
|
||||||
|
|
||||||
|
bool _Disposed;
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (_Disposed)
|
||||||
|
return;
|
||||||
|
_Disposed = true;
|
||||||
lock (this.aggregator._Subscriptions)
|
lock (this.aggregator._Subscriptions)
|
||||||
{
|
{
|
||||||
if (this.aggregator._Subscriptions.TryGetValue(t, out Dictionary<Subscription, Action<object>> actions))
|
if (this.aggregator._Subscriptions.TryGetValue(t, out Dictionary<Subscription, Action<object>> actions))
|
||||||
@@ -51,6 +56,19 @@ namespace BTCPayServer
|
|||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Task<T> WaitNext<T>(CancellationToken cancellation = default(CancellationToken))
|
||||||
|
{
|
||||||
|
return WaitNext<T>(o => true, cancellation);
|
||||||
|
}
|
||||||
|
public async Task<T> WaitNext<T>(Func<T, bool> predicate, CancellationToken cancellation = default(CancellationToken))
|
||||||
|
{
|
||||||
|
TaskCompletionSource<T> tcs = new TaskCompletionSource<T>();
|
||||||
|
var subscription = Subscribe<T>((a, b) => { if (predicate(b)) { tcs.TrySetResult(b); a.Unsubscribe(); } });
|
||||||
|
using (cancellation.Register(() => { tcs.TrySetCanceled(); subscription.Unsubscribe(); }))
|
||||||
|
{
|
||||||
|
return await tcs.Task.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Publish<T>(T evt) where T : class
|
public void Publish<T>(T evt) where T : class
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user