public EnqueueAndSendAsyncResult(Message message, TimeSpan timeout, MakeConnectionDispatcher dispatcher, AsyncCallback callback, object state) : base(callback, state) { this.dispatcher = dispatcher; this.message = message; this.timeoutHelper = new TimeoutHelper(timeout); MessagePendingHeader.AddToMessage(message, this.dispatcher.HasPendingSends); if (message.Headers.RelatesTo == null || !this.dispatcher.TryGetContextForMessageId(message.Headers.RelatesTo, out this.context)) { IAsyncResult result = dispatcher.contexts.BeginDequeue(timeoutHelper.RemainingTime(), onContextDequeueCompleted, this); if (result.CompletedSynchronously) { if (OnContextDequeueCompletedCore(result)) { base.Complete(true); } } } else { IAsyncResult result = this.context.BeginTryReply(this.message, this.timeoutHelper.RemainingTime(), onReplyCompleted, this); if (result.CompletedSynchronously) { if (OnReplyCompletedCore(result)) { base.Complete(true); } } } }
protected override void OnSend(Message message, TimeSpan timeout) { Uri to = EnsureAnonymous(message); MakeConnectionDispatcher dispatcher = this.DispatcherManager.Get(to); dispatcher.EnqueueAndSendMessage(message, timeout); dispatcher.Release(); }
public SendAsyncResult(MakeConnectionDispatcher dispatcher, Message message, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.dispatcher = dispatcher; IAsyncResult result = this.dispatcher.BeginEnqueueAndSendMessage(message, timeout, onSendCompleted, this); if (result.CompletedSynchronously) { OnSendCompletedCore(result); base.Complete(true); } }
public void Shutdown() { lock (dispatchers) { MakeConnectionDispatcher[] arrayOfDispatchers = new MakeConnectionDispatcher[dispatchers.Count]; dispatchers.Values.CopyTo(arrayOfDispatchers, 0); for (int i = 0; i < arrayOfDispatchers.Length; i++) { arrayOfDispatchers[i].Shutdown(); dispatchers.Remove(arrayOfDispatchers[i].Uri); } } }
void Cleanup() { if (this.dispatcher != null) { lock (ThisLock) { if (this.dispatcher != null) { this.dispatcher.Release(); this.dispatcher = null; } } } }
public MakeConnectionDispatcher Get(Uri uri) { MakeConnectionDispatcher dispatcher = null; lock (dispatchers) { if (!dispatchers.TryGetValue(uri, out dispatcher)) { dispatcher = new MakeConnectionDispatcher(uri, dispatchers); dispatchers.Add(uri, dispatcher); dispatcher.ReferencesReleased += new EventHandler(OnReferencesReleased); } dispatcher.AddRef(); } return dispatcher; }
public MakeConnectionDispatcher Get(Uri uri) { MakeConnectionDispatcher dispatcher = null; lock (dispatchers) { if (!dispatchers.TryGetValue(uri, out dispatcher)) { dispatcher = new MakeConnectionDispatcher(uri, dispatchers); dispatchers.Add(uri, dispatcher); dispatcher.ReferencesReleased += new EventHandler(OnReferencesReleased); } dispatcher.AddRef(); } return(dispatcher); }
public MakeConnectionRequestContext(MakeConnectionDispatcherManager dispatcherManager, RequestContext innerContext, TimeSpan pollTimeout, IDefaultCommunicationTimeouts timeouts) { this.innerContext = innerContext; this.pollTimeout = pollTimeout; this.timeouts = timeouts; this.thisLock = new object(); if (this.RequestMessage != null) { this.IsMakeConnectionPollingMessage = (this.RequestMessage.Headers.Action == MakeConnectionConstants.MakeConnectionMessage.Action); this.RequestMesssageId = this.RequestMessage.Headers.MessageId; EndpointAddress address = GetAddress(); if (address != null && this.addressIsAnonymousUri) { this.dispatcher = dispatcherManager.Get(address.Uri); if (this.RequestMesssageId != null) { this.dispatcher.AddContext(this); } } } }
public EnqueueData(MakeConnectionDispatcher dispatcher, MakeConnectionRequestContext oldContext, MakeConnectionRequestContext newContext) { this.Dispatcher = dispatcher; this.OldContext = oldContext; this.NewContext = newContext; }