private void MulticastMessage(IEnumerable <string> view, Message message, AsyncCallback asyncCallback, bool waitForAll) { var replyResult = new ReplyResult(message, waitForAll); lock (ReplyResultQueue) { ReplyResultQueue.TryAdd(message, replyResult); } foreach (var remoteUrl in view) { try { lock (ReplyResultQueue) { replyResult.AddRemoteUrl(remoteUrl); } MulticastSingleUrl(remoteUrl, message, asyncCallback); } catch (Exception e) { // if connection failed, it means it's dead. moving on... lock (ReplyResultQueue){ replyResult.RemoveRemoteUrl(remoteUrl); //TODO is this necessary, or does the try do some rollback? } } } }
public void SingleCastMessage(string remoteUrl, Message message) { var replyResult = new ReplyResult(message, false); lock (ReplyResultQueue) { ReplyResultQueue.TryAdd(message, replyResult); } try { lock (ReplyResultQueue) { replyResult.AddRemoteUrl(remoteUrl); } MulticastSingleUrl(remoteUrl, message, WaitAnyCallback); } catch (Exception e) { // if connection failed, it means it's dead. moving on... lock (ReplyResultQueue){ replyResult.RemoveRemoteUrl(remoteUrl); //TODO is this necessary, or does the try do some rollback? } throw; } }