Fix missing event PoolJobFinished, cleanup

dev_timestamp
Harald Wolff 2019-09-12 11:46:11 +02:00
parent 0d2d128b5f
commit 42f330381e
1 changed files with 4 additions and 8 deletions

View File

@ -41,12 +41,6 @@ namespace ln.types.threads
private Queue<PoolJob> queuedJobs = new Queue<PoolJob>();
private bool stopping;
private int releaseThreads = 0;
private Thread supervisorThread;
public Pool() : this(Environment.ProcessorCount){}
public Pool(int numThreads)
{
@ -58,12 +52,12 @@ namespace ln.types.threads
if ((State == PoolState.RUN) || (State == PoolState.SHUTDOWN))
throw new NotSupportedException("Pool can only be started if not running");
State = PoolState.RUN;
for (int n = 0; n < PoolSize; n++)
{
CreatePoolThread();
}
State = PoolState.RUN;
}
public virtual void Stop() => Stop(false);
@ -217,6 +211,8 @@ namespace ln.types.threads
try
{
poolJob.Run(this);
if (PoolJobFinished != null)
PoolJobFinished(this,poolJob);
}
finally
{