Skip to content

Commit dd6a93d

Browse files
committed
- attempting dispose on processor/factory
1 parent 868abc2 commit dd6a93d

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

Shuttle.Core.Threading/ProcessorThread.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading;
33
using Shuttle.Core.Configuration;
44
using Shuttle.Core.Logging;
5+
using Shuttle.Core.Reflection;
56

67
namespace 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);

Shuttle.Core.Threading/ProcessorThreadPool.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3+
using Shuttle.Core.Contract;
34
using Shuttle.Core.Logging;
5+
using Shuttle.Core.Reflection;
46

57
namespace 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;

0 commit comments

Comments
 (0)