public override bool HandleTaskRequest(RequestObjectMessage container, BaseRequestObject requestObject)
 {
     var request = (RequestObject)requestObject;
     request.Return = -request.RequestId;
     if (BatchSize == 1) Interlocked.Increment(ref _callsCount);
     Thread.Sleep(_waitTimeMs);
     return true;
 }
Пример #2
0
 public long DoRequestAndWait(BaseRequestObject requestObject, int timeoutMs, string senderId = null)
 {
     if (requestObject == null) throw new ArgumentNullException("requestObject");
     if (timeoutMs < 0) throw new ArgumentException("Parameter must be greater than 0", "timeoutMs");
     var msg = new RequestObjectMessage(requestObject, timeoutMs) { SourceThread = senderId };
     SendMessageToThread(msg);
     var sw = new Stopwatch();
     sw.Start();
     msg.Wait();
     sw.Stop();
     return sw.ElapsedMilliseconds;
 }
Пример #3
0
 public abstract bool HandleTaskRequest(RequestObjectMessage container, BaseRequestObject requestObject);
Пример #4
0
        public void FireAndForget(BaseRequestObject requestObject, int timeoutMs, string senderId = null)
        {
            if (requestObject == null) throw new ArgumentNullException("requestObject");
            if (timeoutMs < 0) throw new ArgumentException("Parameter must be greater than 0", "timeoutMs");

            var msg = new RequestObjectMessage(requestObject, timeoutMs) { SourceThread = senderId };
            SendMessageToThread(msg);
        }