File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22using System . Threading ;
33using Shuttle . Core . Configuration ;
44using Shuttle . Core . Logging ;
5+ using Shuttle . Core . Reflection ;
56
67namespace Shuttle . Core . Threading
78{
@@ -43,7 +44,7 @@ public void Start()
4344 }
4445 catch ( Exception ex )
4546 {
46- #if ! NETCOREAPP2_0 && ! NETCOREAPP2_1
47+ #if ! NETCOREAPP2_1
4748 _log . Warning ( ex . Message ) ;
4849#else
4950 _log . Information ( ex . Message ) ;
@@ -84,6 +85,8 @@ public void Stop()
8485
8586 _active = false ;
8687
88+ _processor . AttemptDispose ( ) ;
89+
8790 if ( _thread . IsAlive )
8891 {
8992 _thread . Join ( ThreadJoinTimeoutInterval ) ;
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using Shuttle . Core . Contract ;
34using Shuttle . Core . Logging ;
5+ using Shuttle . Core . Reflection ;
46
57namespace Shuttle . Core . Threading
68{
@@ -16,7 +18,14 @@ public class ProcessorThreadPool : IProcessorThreadPool
1618
1719 public ProcessorThreadPool ( string name , int threadCount , IProcessorFactory processorFactory )
1820 {
19- _name = name ;
21+ Guard . AgainstNull ( processorFactory , nameof ( processorFactory ) ) ;
22+
23+ if ( _threadCount < 1 )
24+ {
25+ throw new ThreadCountZeroException ( ) ;
26+ }
27+
28+ _name = name ?? Guid . NewGuid ( ) . ToString ( ) ;
2029 _threadCount = threadCount ;
2130 _processorFactory = processorFactory ;
2231
@@ -50,11 +59,6 @@ public IProcessorThreadPool Start()
5059 return this ;
5160 }
5261
53- if ( _threadCount < 1 )
54- {
55- throw new ThreadCountZeroException ( ) ;
56- }
57-
5862 StartThreads ( ) ;
5963
6064 _started = true ;
@@ -103,6 +107,8 @@ protected virtual void Dispose(bool disposing)
103107 {
104108 thread . Stop ( ) ;
105109 }
110+
111+ _processorFactory . AttemptDispose ( ) ;
106112 }
107113
108114 _disposed = true ;
You can’t perform that action at this time.
0 commit comments