コード例 #1
0
 /// <summary>
 /// 停止运行单个
 /// </summary>
 /// <param name="id"></param>
 /// <param name="callback"></param>
 public void StopOnThread(int id, T2 callback)
 {
     lock (lockObj)
     {
         LoomLinkList <T1, T2> linkList = null;
         if (_current.ContainsKey(id))
         {
             linkList = _current[id];
         }
         else if (_Actions.ContainsKey(id))
         {
             linkList = _Actions[id];
         }
         if (linkList == null)
         {
             return;
         }
         LoomThreadObject <T2> currentNode = linkList.Head as LoomThreadObject <T2>;
         while (currentNode != null)
         {
             if ((object)currentNode.callback == (object)callback)
             {
                 currentNode.OnStop();
                 break;
             }
             currentNode = currentNode.Next as LoomThreadObject <T2>;
         }
     }
 }
コード例 #2
0
            public void OnDispose()
            {
                LoomThreadObject <T2> loomObj = Head as LoomThreadObject <T2>;

                loomObj.OnStop();
                while (loomObj.Next != null)
                {
                    loomObj = loomObj.Next as LoomThreadObject <T2>;
                    loomObj.OnStop();
                }
                currentNode = null;
            }
コード例 #3
0
            public void OnUpdate()
            {
                switch (_status)
                {
                case "NOTWORKING":
                    _status = "WORKING";
                    lock (LockObj)
                    {
                        currentNode = Head as LoomThreadObject <T2>;
                        m_RunIndex++;
                    }
                    break;

                case "WORKING":
                    if (currentNode == null)
                    {
                        _status = "END";
                        return;
                    }
                    switch (currentNode.status)
                    {
                    case "NOTWORKING":
                        currentNode.Invoke();
                        break;

                    case "WORKING":
                        currentNode.OnUpdate();
                        break;

                    case "END":
                        if (currentNode.Next != null)
                        {
                            lock (LockObj)
                            {
                                currentNode = currentNode.Next as LoomThreadObject <T2>;
                                m_RunIndex++;
                            }
                        }
                        else
                        {
                            _status = "END";
                        }
                        break;
                    }
                    break;
                }
            }
コード例 #4
0
            public void OnStart()
            {
                switch (_status)
                {
                case "NOTWORKING":
                    _status     = "WORKING";
                    currentNode = Head as LoomThreadObject <T2>;
                    break;

                case "END":
                    if (currentNode == null || currentNode.Next == null)
                    {
                        return;
                    }
                    _status     = "WORKING";
                    currentNode = currentNode.Next as LoomThreadObject <T2>;
                    break;
                }
            }