Пример #1
0
        private static IEnumerator PreformThreadedOperation(Action threadedOperation)
        {
            var thread = new Thread(new ThreadStart(threadedOperation));

            thread.Start();

            yield return(TinyCoro.WaitUntil(() => !thread.IsAlive));
        }
Пример #2
0
 /// <summary>
 /// Adds an new TinyCoro to the pool after the currently exceutiny one (or last if none are running) 
 /// </summary>
 /// <param name="threadedOperation"></param>
 /// <returns></returns>
 public static TinyCoro SpawnNext(Func<IEnumerator> operation)
 {
     var coro = new TinyCoro(operation);
     var index = _allCoros.Count;
     if (_currentCoro != null)
         index = _allCoros.IndexOf(_currentCoro) + 1;
     _allCoros.Insert(index, coro);
     return coro;
 }
Пример #3
0
        /// <summary>
        /// Adds an new TinyCoro to the pool after the currently exceutiny one (or last if none are running)
        /// </summary>
        /// <param name="threadedOperation"></param>
        /// <returns></returns>
        public static TinyCoro SpawnNext(Func <IEnumerator> operation)
        {
            var coro  = new TinyCoro(operation);
            var index = _allCoros.Count;

            if (_currentCoro != null)
            {
                index = _allCoros.IndexOf(_currentCoro) + 1;
            }
            _allCoros.Insert(index, coro);
            return(coro);
        }
Пример #4
0
 public static TinyCoro SpawnAfter(Action threadedOperation)
 {
     return(TinyCoro.SpawnNext(() => PreformThreadedOperation(threadedOperation)));
 }
Пример #5
0
 public static void StepAllCoros()
 {
     for (int i = 0; i < _allCoros.Count; )
     {
         //Step normal
         _currentCoro = _allCoros[i];
         if (_currentCoro.Alive)
             _currentCoro.Step();
         if (!_currentCoro.Alive)
         {
             _allCoros.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
     _currentCoro = null;
 }