Refactored error handler for events

This commit is contained in:
watsonb8 2019-11-29 20:54:49 -05:00
parent e822829cc0
commit 8bea1d03da

View File

@ -182,7 +182,14 @@ namespace Aurora.Services.EventManager
{
actionsCopy.TryGetValue(pair.Key, out Action<BaseEvent> 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
}