Added Pacore
This commit is contained in:
24
Assets/Pacore/Runtime/Threading/ThreadSafeTry.cs
Normal file
24
Assets/Pacore/Runtime/Threading/ThreadSafeTry.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace PashaBibko.Pacore.Threading
|
||||
{
|
||||
public static partial class ThreadSafe
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Try(Action action, Action final = null)
|
||||
{
|
||||
try { action(); }
|
||||
|
||||
/* Makes sure any exceptions are caught and logged properly */
|
||||
catch (Exception ex)
|
||||
{
|
||||
ThreadDispatcher.QueueImmediate(() => Debug.Log($"Exception: [{ex.Message}]"));
|
||||
throw;
|
||||
}
|
||||
|
||||
finally { final?.Invoke(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user