예제 #1
0
 public static T ApplySelfTo <T>(this T selfObj, System.Action <T> toFunction) where T : Object
 {
     toFunction.InvokeGracefully(selfObj);
     return(selfObj);
 }
예제 #2
0
        private IEnumerator Runner()
        {
            bool     isTimeup = false;
            DateTime timer    = DateTime.Now;

            yield return(null);

            IEnumerator enumerator = mEnumerator;

            while (mIsRunning)
            {
                if (mTimer > 0)
                {
                    System.TimeSpan tsc = DateTime.Now - timer;
                    if (tsc.Seconds > mTimer)
                    {
                        isTimeup = true;
                        break;
                    }
                }

                if (mIsPaused)
                {
                    yield return(null);
                }
                else
                {
                    bool isFinish = false;
                    try
                    {
                        isFinish = enumerator.MoveNext();
                    }
                    catch (Exception e)
                    {
                        isFinish   = false;
                        mIsRunning = false;

                        mLogger.LogError(string.Format("{0}: {1}", mName, e.Message));
                        mLogger.LogException(e);
                    }

                    if ((enumerator != null) && isFinish)
                    {
                        yield return(enumerator.Current);
                    }
                    else
                    {
                        mIsRunning = false;
                    }
                }
            }

            if (!isTimeup)
            {
                mOnFinished.InvokeGracefully(mIsStopped);
            }
            else
            {
                mOnTimeup.InvokeGracefully();
            }

            if (mMgr != null)
            {
                int index = mMgr.Container.IndexOf(this);
                if (index >= 0)
                {
                    mMgr.Container.RemoveAt(index);
                }
            }
        }