Exemple #1
0
        /// <summary>
        /// Sends the query message to the named service instance and waits for
        /// a reply.
        /// </summary>
        /// <param name="serviceName">The service name.</param>
        /// <param name="query">The query message.</param>
        /// <returns>The reply message.</returns>
        /// <remarks>
        /// Throws a TimeoutException if the service doesn't respond by MaxWaitTime.
        /// </remarks>
        private ServiceMsg Query(string serviceName, ServiceMsg query)
        {
            using (TimedLock.Lock(this))
            {
                refID       = Helper.NewGuid();
                query.RefID = refID;
            }

            query["Reply-To"] = ControlMemPrefix + id.ToString();

            outbox.Send(ServiceMemPrefix + serviceName, query.ToBytes());
            if (!onReply.WaitOne(MaxWaitTime, false))
            {
                throw new System.TimeoutException();
            }

            if (reply.Command != "Ack")
            {
                throw new InvalidOperationException("Invalid Service response.");
            }

            return(reply);
        }
Exemple #2
0
 public void ThreadProc()
 {
     startTime = SysTime.Now;
     event2.WaitOne();
     finishTime = SysTime.Now;
 }