/// <summary> /// 要求を待つ /// </summary> /// <param name="wait">待つ要求</param> /// <param name="milliseconds">待ちミリ秒</param> /// /// <returns>受信した要求</returns> public RequestBase Wait(RequestBase wait, long milliseconds) { RequestBase received = null; RequestBase likes = null; var end = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); while ((DateTime.Now.CompareTo(end) < 0) && this.IsOpened && (!wait.Equals(received))) { var receiving = this.Receive(); received = (receiving != null) ? receiving : received; likes = ((receiving != null) && receiving.Likes(wait)) ? receiving : likes; } var result = wait.Equals(received) ? received : likes; return((result == null) ? new NoOperation() : result); }