Skip to content

Commit

Permalink
Upgraded to LiquidProjections.PollingEventStore.Sources 1.1.1 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
IharBury authored and dennisdoomen committed Sep 18, 2017
1 parent acb4730 commit 9b9d4de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Start()
exception);
}
},
cancellationTokenSource.Token,
CancellationToken.None,
TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning,
TaskScheduler.Default)
.Unwrap();
Expand Down Expand Up @@ -169,43 +169,47 @@ public void Dispose()
{
isDisposed = true;

// Wait for the task asynchronously.
Task.Run(() =>
{
if (cancellationTokenSource != null)
{
#if DEBUG
LogProvider.GetLogger(typeof(Subscription)).Debug(() => $"Subscription {Id} is being stopped.");
LogProvider.GetLogger(typeof(Subscription)).Debug(() => $"Subscription {Id} is being stopped.");
#endif

if (!cancellationTokenSource.IsCancellationRequested)
{
cancellationTokenSource.Cancel();
}
try
{
Task?.Wait();
}
catch (AggregateException)
{
// Ignore.
}
cancellationTokenSource.Dispose();
if (cancellationTokenSource != null)
{
try
{
cancellationTokenSource.Cancel();
}
lock (eventStoreAdapter.subscriptionLock)
catch (AggregateException)
{
eventStoreAdapter.subscriptions.Remove(this);
// Ignore.
}
}

#if DEBUG
LogProvider.GetLogger(typeof(Subscription)).Debug(() => $"Subscription {Id} has been stopped.");
#endif
});
lock (eventStoreAdapter.subscriptionLock)
{
eventStoreAdapter.subscriptions.Remove(this);
}

if (Task == null)
{
FinishDisposing();
}
else
{
// Wait for the task asynchronously.
Task.ContinueWith(_ => FinishDisposing());
}
}
}
}

private void FinishDisposing()
{
cancellationTokenSource?.Dispose();

#if DEBUG
LogProvider.GetLogger(typeof(Subscription)).Debug(() => $"Subscription {Id} has been stopped.");
#endif
}
}
}
2 changes: 1 addition & 1 deletion Src/LiquidProjections.NEventStore/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LiquidProjections.Abstractions" version="2.3.0" targetFramework="net45" />
<package id="LiquidProjections.PollingEventStore.Sources" version="1.1.0" targetFramework="net45" />
<package id="LiquidProjections.PollingEventStore.Sources" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net45" />
<package id="NEventStore" version="5.2.0" targetFramework="net45" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net45" />
Expand Down

0 comments on commit 9b9d4de

Please sign in to comment.