From 8bea1d03daa0fdc3f9d62d6523f1dbaa685390c3 Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Fri, 29 Nov 2019 20:54:49 -0500 Subject: [PATCH] Refactored error handler for events --- Aurora/Services/EventManager/EventManager.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Aurora/Services/EventManager/EventManager.cs b/Aurora/Services/EventManager/EventManager.cs index cd5858a..8b41e43 100644 --- a/Aurora/Services/EventManager/EventManager.cs +++ b/Aurora/Services/EventManager/EventManager.cs @@ -182,7 +182,14 @@ namespace Aurora.Services.EventManager { actionsCopy.TryGetValue(pair.Key, out Action action); Task executionTask = new Task(() => action(bEvent)); - executionTask.ContinueWith((Task task) => ExceptionHandler(task, pair.Key), + + //Execute task with exception handler + executionTask.ContinueWith((Task task) => + { + var exception = executionTask.Exception; + Console.WriteLine(string.Format("SERVER --- Exception occurred firing event")); + this._actionList.Remove(pair.Key); + }, TaskContinuationOptions.OnlyOnFaulted); executionTask.Start(); @@ -192,13 +199,6 @@ namespace Aurora.Services.EventManager } - private void ExceptionHandler(Task executionTask, string actionKey) - { - var exception = executionTask.Exception; - Console.WriteLine(string.Format("SERVER --- Exception occurred firing event")); - this._actionList.Remove(actionKey); - } - #endregion Public Methods }