private object ThreadPoolRoutine(object state) { if (!(state is UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask scheduledTask)) { throw new ArgumentException("Unexpected state object or null", nameof(state)); } try { bool taskExecuted = false; Exception ex1 = (Exception)null; using (LocaleThreadState.EnsurePrimaryLocale()) { if (!SmartThreadPool.get_IsWorkItemCanceled()) { try { taskExecuted = true; this.taskRoutine(scheduledTask.TaskKey); } catch (Exception ex2) { ex1 = ex2; this.log.Error((object)string.Format("Task {0} cought unhandled exception from task routine", (object)scheduledTask), ex2); } } if (scheduledTask.Callbacks != null) { foreach (UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTaskCallback callback in scheduledTask.Callbacks) { try { callback.Callback(new UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTaskCallbackEventArgs(scheduledTask.TaskKey, callback.State, ex1, taskExecuted)); } catch (Exception ex2) { this.log.Error((object)string.Format("Task {0} callback failed", (object)scheduledTask), ex2); } } } } } catch (Exception ex) { this.log.Error((object)string.Format("Task {0} cought unhandled exception during task processing", (object)scheduledTask), ex); } finally { lock (this.syncLock) this.ongoingTasks.Remove(scheduledTask); } return((object)null); }
private object ThreadPoolCallBack(object state) { if (state is TTask task) { try { if (!SmartThreadPool.get_IsWorkItemCanceled()) { using (LocaleThreadState.EnsurePrimaryLocale()) this.processingRoutine(task); } } catch (Exception ex) { QueuedTaskScheduler <TTask> .log.Error((object)"Unhandled exception in queued task processing:", ex); } } return((object)null); }