Mono.MicroThreads.MicroThread.Yield C# (CSharp) Метод

Yield() публичный Метод

public Yield ( ) : void
Результат void
        public void Yield()
        {
            if (m_state != MicroThreadState.Running)
            {
                throw new Exception(String.Format("Illegal thread state in Yield(): {0}", m_state));
            }

            #if EXTRA_CHECKS
            if (CurrentThread != this)
            {
                throw new Exception("Trying to yield a non-current thread");
            }
            #endif
            Scheduler.Yield();
        }

Usage Example

Пример #1
0
        public void Send(T data)
        {
            MicroThread t = MicroThread.CurrentThread;

            m_dataQueue.Enqueue(data);

            if (m_receivers.Count == 0)
            {
                m_senders.Enqueue(t);
                t.Wait();
            }
            else
            {
                MicroThread receiver = m_receivers.Dequeue();
                receiver.WakeUp();
                t.Yield();
            }
        }