Browse Source

Fixed exception thrown when terminate the program with Ctrl+C. (#130)

undefined
Savorboard 6 years ago
parent
commit
120b794645
2 changed files with 11 additions and 5 deletions
  1. +1
    -0
      CAP.sln
  2. +10
    -5
      src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs

+ 1
- 0
CAP.sln View File

@@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
CHANGELOG.md = CHANGELOG.md CHANGELOG.md = CHANGELOG.md
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
ConfigureMSDTC.ps1 = ConfigureMSDTC.ps1 ConfigureMSDTC.ps1 = ConfigureMSDTC.ps1
.github\ISSUE_TEMPLATE = .github\ISSUE_TEMPLATE
LICENSE.txt = LICENSE.txt LICENSE.txt = LICENSE.txt
README.md = README.md README.md = README.md
README.zh-cn.md = README.zh-cn.md README.zh-cn.md = README.zh-cn.md


+ 10
- 5
src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs View File

@@ -57,13 +57,14 @@ namespace DotNetCore.CAP.Processor
return; return;
} }


_disposed = true;

_logger.ServerShuttingDown();
_cts.Cancel();
try try
{ {
_compositeTask.Wait((int) TimeSpan.FromSeconds(10).TotalMilliseconds);
_disposed = true;

_logger.ServerShuttingDown();
_cts.Cancel();

_compositeTask?.Wait((int)TimeSpan.FromSeconds(10).TotalMilliseconds);
} }
catch (AggregateException ex) catch (AggregateException ex)
{ {
@@ -73,6 +74,10 @@ namespace DotNetCore.CAP.Processor
_logger.ExpectedOperationCanceledException(innerEx); _logger.ExpectedOperationCanceledException(innerEx);
} }
} }
catch (Exception ex)
{
_logger.LogWarning(ex, "An exception was occured when disposing...");
}
} }


private IProcessor InfiniteRetry(IProcessor inner) private IProcessor InfiniteRetry(IProcessor inner)


Loading…
Cancel
Save