public object SendRequest(Message message) { var context = new CompletionSource <object>(); contexts[message.Guid] = context; try { SendMessage(message); var membershipServiceOptions = GetMembershipServiceOptions(message.SendingSlio); return(context.GetResult(membershipServiceOptions.RequestTimeout)); } finally { contexts.TryRemove(message.Guid, out _); context.Dispose(); } }