/// <summary> /// Fire and forget: The MainThread will execute this method witout any arguments to pass, nothing will be returned. /// </summary> /// <param name="dispatchCall">Example: "() => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name)" </param> /// <param name="waitForExecution">Freezes the thread, waiting for the MainThread to execute & finish the "dispatchCall".</param> /// <param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace</param> public static void DispatchToMainThread(ThreadDispatchDelegate dispatchCall, bool waitForExecution = false, bool safeMode = true) { ThreadDispatchAction action = new ThreadDispatchAction(); lock (dispatchActions) { dispatchActions.Add(action); } action.Init(dispatchCall, waitForExecution, safeMode); }
//--------------------------------------- UPDATE CALLED BY HELPER -------------------------------------- //--------------------------------------- UPDATE CALLED BY HELPER -------------------------------------- //--------------------------------------- 4 DISPATCH OVERLOADS -------------------------------------- //--------------------------------------- 4 DISPATCH OVERLOADS -------------------------------------- #region 4 DISPATCH OVERLOADS /// <summary> /// Fire and forget: The MainThread will execute this method witout any arguments to pass, nothing will be returned. /// </summary> /// <param name="dispatchCall">Example: "() => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name)" </param> /// <param name="waitForExecution">Freezes the thread, waiting for the MainThread to execute & finish the "dispatchCall".</param> /// <param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace</param> public static void DispatchToMainThread(ThreadDispatchDelegate dispatchCall, bool waitForExecution = false, bool safeMode = true) { ThreadDispatchAction action = new ThreadDispatchAction(); lock (dispatchActions) { dispatchActions.Add(action); } action.Init(dispatchCall, waitForExecution, safeMode); }
/// <summary> /// Fire and forget: The MainThread will execute this method witout any arguments to pass, nothing will be returned. /// </summary> /// <param name="dispatchCall">Example: "() => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name)" </param> /// <param name="waitForExecution">Freezes the thread, waiting for the MainThread to execute & finish the "dispatchCall".</param> /// <param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace</param> public static void DispatchToMainThread(ThreadDispatchDelegate dispatchCall, bool waitForExecution = false, bool safeMode = true) { if (MainThreadWatchdog.CheckIfMainThread()) { if (dispatchCall != null) dispatchCall(); } else { ThreadDispatchAction action = new ThreadDispatchAction(); lock (dispatchActions) { dispatchActions.Add(action); } action.Init(dispatchCall, waitForExecution, safeMode); } }
//--------------------------------------- UPDATE CALLED BY HELPER -------------------------------------- //--------------------------------------- UPDATE CALLED BY HELPER -------------------------------------- //--------------------------------------- 4 DISPATCH OVERLOADS -------------------------------------- //--------------------------------------- 4 DISPATCH OVERLOADS -------------------------------------- #region 4 DISPATCH OVERLOADS /// <summary> /// Fire and forget: The MainThread will execute this method witout any arguments to pass, nothing will be returned. /// </summary> /// <param name="dispatchCall">Example: "() => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name)" </param> /// <param name="waitForExecution">Freezes the thread, waiting for the MainThread to execute & finish the "dispatchCall".</param> /// <param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace</param> public static void DispatchToMainThread(ThreadDispatchDelegate dispatchCall, bool waitForExecution = false, bool safeMode = true) { if (MainThreadWatchdog.CheckIfMainThread()) { if (dispatchCall != null) { dispatchCall(); } } else { ThreadDispatchAction action = new ThreadDispatchAction(); lock (dispatchActions) { dispatchActions.Add(action); } action.Init(dispatchCall, waitForExecution, safeMode); } }
internal static void DispatchToMainThread(ThreadDispatchDelegate dispatchCall, bool safeMode = true) { if (MainThreadDispatchHelper.CheckIfMainThread()) { if (dispatchCall != null) { dispatchCall.Invoke(); } } else { var action = new ThreadDispatchAction(); lock (DispatchActions) { DispatchActions.Add(action); } action.Init(dispatchCall, safeMode); } }
public void Init(ThreadDispatchDelegate dispatchCall, bool safeMode) { _safeMode = safeMode; _dispatchCallClean = dispatchCall; }
//--------------------------------------- 4 DIFFERENT OVERLOADS -------------------------------------- //--------------------------------------- 4 DIFFERENT OVERLOADS -------------------------------------- #region 4 DIFFERENT OVERLOADS public void Init(ThreadDispatchDelegate dispatchCall, bool waitForExecution, bool safeMode) { this.safeMode = safeMode; this.dispatchCallClean = dispatchCall; ValidateExecutionOnInit(waitForExecution); }
//--------------------------------------- THREAD WAIT COMMANDS -------------------------------------- //--------------------------------------- THREAD WAIT COMMANDS -------------------------------------- //--------------------------------------- 4 DISPATCHER OVERLOADS -------------------------------------- //--------------------------------------- 4 DISPATCHER OVERLOADS -------------------------------------- #region 4 DISPATCHER OVERLOADS /// <summary> /// Fire and forget: The MainThread will execute this method witout any arguments to pass, nothing will be returned. /// </summary> /// <param name="dispatchCall">Example: "() => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name)" </param> /// <param name="waitForExecution">Freezes the thread, waiting for the MainThread to execute & finish the "dispatchCall".</param> /// <param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace</param> public static void DispatchToMainThread(ThreadDispatchDelegate dispatchCall, bool waitForExecution = false, bool safeMode = true) { MainThreadDispatcher.DispatchToMainThread(dispatchCall, waitForExecution, safeMode); }
public void Init(ThreadDispatchDelegate dispatchCall, bool waitForExecution, bool safeMode) { this.safeMode = safeMode; this.dispatchCallClean = dispatchCall; ValidateExecutionOnInit(waitForExecution); }