コード例 #1
0
ファイル: ErlLocalNode.cs プロジェクト: sergey-msu/nfx
 /// <summary>
 /// Wait for arrival of messages in any one of the given mailboxes
 /// </summary>
 /// <param name="mboxes">Mailboxes to wait for messages in</param>
 /// <param name="msecTimeout">Timeout in milliseconds</param>
 /// <returns>Index of the first non-empty mailbox or -1 on timeout</returns>
 public int WaitAny(ErlMbox[] mboxes, int msecTimeout = -1)
 {
     for(int i = 0; i < mboxes.Length; i++)
         if (!mboxes[i].Empty)
             return i;
     if (msecTimeout == 0)
         return -1;
     int n = WaitHandle.WaitAny(mboxes.Select(m => m.Handle).ToArray(), msecTimeout);
     return n == WaitHandle.WaitTimeout ? -1 : n;
 }