Exemplo n.º 1
0
    public void ProcessQueue()
    {
        if (Thread.CurrentThread != mainThread)
        {
            throw new Exception("Must be called from the same thread it was created on");
        }
        bool             loop = true;
        UnityAsyncResult data = null;

        while (loop)
        {
            lock (fifoToExecute)
            {
                loop = fifoToExecute.Count > 0;
                if (!loop)
                {
                    break;
                }
                data = fifoToExecute.Dequeue();
            }

            data.AsyncState  = Invoke(data.method, data.args);
            data.IsCompleted = true;
        }
    }
    public void ProcessQueue()
    {
        if (Thread.CurrentThread != mainThread)
        {
            throw new TargetException(
                      this.GetType() + "." + MethodBase.GetCurrentMethod().Name + "() " +
                      "must be called from the same thread it was created on " +
                      "(created on thread id: " + mainThread.ManagedThreadId + ", called from thread id: " + Thread.CurrentThread.ManagedThreadId
                      );
        }
        bool             loop = true;
        UnityAsyncResult data = null;

        while (loop)
        {
            lock (fifoToExecute)
            {
                loop = fifoToExecute.Count > 0;
                if (!loop)
                {
                    break;
                }
                data = fifoToExecute.Dequeue();
            }

            data.AsyncState  = Invoke(data.method, data.args);
            data.IsCompleted = true;
        }
    }
 public IAsyncResult BeginInvoke(Delegate method, object[] args)
 {
     var asyncResult = new UnityAsyncResult()
     {
         method = method,
         args = args,
         IsCompleted = false,
         AsyncWaitHandle = new ManualResetEvent(false),
     };
     lock (fifoToExecute)
     {
         fifoToExecute.Enqueue(asyncResult);
     }
     return asyncResult;
 }
Exemplo n.º 4
0
    public IAsyncResult BeginInvoke(Delegate method, object[] args)
    {
        var asyncResult = new UnityAsyncResult()
        {
            method          = method,
            args            = args,
            IsCompleted     = false,
            AsyncWaitHandle = new ManualResetEvent(false),
        };

        lock (fifoToExecute)
        {
            fifoToExecute.Enqueue(asyncResult);
        }
        return(asyncResult);
    }