/// <inheritdoc /> public IWorker Get(Action onRunCallback, Action postCompletedCallback) { if (onRunCallback == null) { throw new ArgumentNullException(nameof(onRunCallback)); } GuardMustNotBeDisposed(); IRuntimeWorker worker = null; try { worker = cache.Get(); if (worker != null) { try { worker.Initialize(new WorkerExecutionContext { OnRunCallback = onRunCallback, PostCompletedCallback = postCompletedCallback }); return(CreatePooledWorker(worker)); } catch (Exception) { worker.Reset(); throw; } } } catch (Exception) { if (worker != null) { cache.Release(worker); } throw; } return(null); }
private void Release() { cache.Release(worker); }