public void Init(ThreadDispatchDelegateArg dispatchCall, object dispatchArgumentParameter, bool waitForExecution, bool safeMode)
 {
     this.safeMode         = safeMode;
     this.dispatchCallArg  = dispatchCall;
     this.dispatchArgParam = dispatchArgumentParameter;
     ValidateExecutionOnInit(waitForExecution);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// When executed by the MainThread, this argument will be passed to the "dispatchCall";
        /// </summary>
        /// <param name="dispatchCall">Example: "(object obj) => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name + "\nObject: " + obj.toString())"</param>
        /// <param name="dispatchArgument">Once the MainThread executes this action, the argument will be passed to the delegate</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(ThreadDispatchDelegateArg dispatchCall, object dispatchArgument, bool waitForExecution = false, bool safeMode = true)
        {
            ThreadDispatchAction action = new ThreadDispatchAction();

            lock (dispatchActions)
            {
                dispatchActions.Add(action);
            }
            action.Init(dispatchCall, dispatchArgument, waitForExecution, safeMode);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// When executed by the MainThread, this argument will be passed to the "dispatchCall";
 /// </summary>
 /// <param name="dispatchCall">Example: "(object obj) => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name + "\nObject: " + obj.toString())"</param>
 /// <param name="dispatchArgument">Once the MainThread executes this action, the argument will be passed to the delegate</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(ThreadDispatchDelegateArg dispatchCall, object dispatchArgument, bool waitForExecution = false, bool safeMode = true)
 {
     if (MainThreadWatchdog.CheckIfMainThread())
     {
         if (dispatchCall != null)
         {
             dispatchCall(dispatchArgument);
         }
     }
     else
     {
         ThreadDispatchAction action = new ThreadDispatchAction();
         lock (dispatchActions) { dispatchActions.Add(action); }
         action.Init(dispatchCall, dispatchArgument, waitForExecution, safeMode);
     }
 }
Ejemplo n.º 4
0
        internal static void DispatchToMainThread(ThreadDispatchDelegateArg dispatchCall, object dispatchArgument,
                                                  bool safeMode = true)
        {
            if (MainThreadDispatchHelper.CheckIfMainThread())
            {
                if (dispatchCall != null)
                {
                    dispatchCall.Invoke(dispatchArgument);
                }
            }
            else
            {
                var action = new ThreadDispatchAction();
                lock (DispatchActions)
                {
                    DispatchActions.Add(action);
                }

                action.Init(dispatchCall, dispatchArgument, safeMode);
            }
        }
 public void Init(ThreadDispatchDelegateArg dispatchCall, object dispatchArgumentParameter, bool safeMode)
 {
     _safeMode         = safeMode;
     _dispatchCallArg  = dispatchCall;
     _dispatchArgParam = dispatchArgumentParameter;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// When executed by the MainThread, this argument will be passed to the "dispatchCall";
 /// </summary>
 /// <param name="dispatchCall">Example: "(object obj) => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name + "\nObject: " + obj.toString())"</param>
 /// <param name="dispatchArgument">Once the MainThread executes this action, the argument will be passed to the delegate</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(ThreadDispatchDelegateArg dispatchCall, object dispatchArgument, bool waitForExecution = false, bool safeMode = true)
 {
     MainThreadDispatcher.DispatchToMainThread(dispatchCall, dispatchArgument, waitForExecution, safeMode);
 }
Ejemplo n.º 7
0
 public void Init(ThreadDispatchDelegateArg dispatchCall, object dispatchArgumentParameter, bool waitForExecution, bool safeMode)
 {
     this.safeMode = safeMode;
     this.dispatchCallArg = dispatchCall;
     this.dispatchArgParam = dispatchArgumentParameter;
     ValidateExecutionOnInit(waitForExecution);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// When executed by the MainThread, this argument will be passed to the "dispatchCall";
 /// </summary>
 /// <param name="dispatchCall">Example: "(object obj) => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name + "\nObject: " + obj.toString())"</param>
 /// <param name="dispatchArgument">Once the MainThread executes this action, the argument will be passed to the delegate</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(ThreadDispatchDelegateArg dispatchCall, object dispatchArgument, bool waitForExecution = false, bool safeMode = true)
 {
     ThreadDispatchAction action = new ThreadDispatchAction();
     lock (dispatchActions)
     {
         dispatchActions.Add(action);
     }
     action.Init(dispatchCall, dispatchArgument, waitForExecution, safeMode);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// When executed by the MainThread, this argument will be passed to the "dispatchCall";
 /// </summary>
 /// <param name="dispatchCall">Example: "(object obj) => Debug.Log("This will be fired from the MainThread: " + System.Threading.Thread.CurrentThread.Name + "\nObject: " + obj.toString())"</param>
 /// <param name="dispatchArgument">Once the MainThread executes this action, the argument will be passed to the delegate</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(ThreadDispatchDelegateArg dispatchCall, object dispatchArgument, bool waitForExecution = false, bool safeMode = true)
 {
     if (MainThreadWatchdog.CheckIfMainThread())
     {
         if (dispatchCall != null)
             dispatchCall(dispatchArgument);
     }
     else
     {
         ThreadDispatchAction action = new ThreadDispatchAction();
         lock (dispatchActions) { dispatchActions.Add(action); }
         action.Init(dispatchCall, dispatchArgument, waitForExecution, safeMode);
     }
 }