public override Task <ParseResult <TResult> > InvokeAsync(TParameter parameter, int timeout = 60000) { return(Task.Factory.StartNew <ParseResult <TResult> >(() => { var telegram = PackParameterToSend(parameter); var waitEvent = new ManualResetEvent(false); ParseResult <TResult> parseResult = null; _telegramExchangeDispatcher.Enqueue(telegram, (telegramReceive) => { var parseWorkItem = new ParseWorkItem <TResult, Telegram>(telegramReceive, _parser); parseWorkItem.ParseFinish += (sender, e) => { // if not found waitEvent meaning timeout then if (waitEvent == null) { return; } parseResult = e.ParseResult; waitEvent.Set(); }; _parserPool.Enqueue(parseWorkItem); }); waitEvent.WaitOne(TimeSpan.FromMilliseconds(timeout)); waitEvent.Dispose(); waitEvent = null; return parseResult; })); }