public void ExecuteDispatch()
        {
            if (_safeMode)
            {
                try
                {
                    if (_dispatchCallClean != null)
                    {
                        _dispatchCallClean();
                    }
                    else
                    {
                        if (_dispatchCallArg != null)
                        {
                            _dispatchCallArg.Invoke(_dispatchArgParam);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
            else
            {
                if (_dispatchCallClean != null)
                {
                    _dispatchCallClean();
                }
                else
                {
                    if (_dispatchCallArg != null)
                    {
                        _dispatchCallArg.Invoke(_dispatchArgParam);
                    }
                }
            }

            Executed = true;
        }
Beispiel #2
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);
            }
        }