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(); } }
public object SendRequest(Message message, TimeSpan timeout) { using (var context = new CompletionSource <object>()) { contexts[message.Guid] = context; SendMessage(message); try { return(context.GetResult(timeout)); } finally { contexts.TryRemove(message.Guid, out _); } } }