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; }
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; }
public abstract bool HandleTaskRequest(RequestObjectMessage container, BaseRequestObject requestObject);
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); }