protected void EnqueueInfoQuery(string type, string from, string to, Action <InfoQueryResponse, CancellationToken> callback, IEnumerable <XElement> content) { QueuedQueries.Enqueue(new InfoQuery { Type = type, From = from, To = to, Content = content, Callback = callback }); QueriesQueued.Set(); }
protected void ProcessQueuedQueries(XmlStream xml, CancellationToken canceltoken) { InfoQuery iq; if (IsReadyForSubscriptions) { Func <InfoQuery> iqfactory; while (!canceltoken.IsCancellationRequested && QueuedSubscriptions.TryDequeue(out iqfactory)) { ProcessInfoQuery(xml, iqfactory()); } } while (!canceltoken.IsCancellationRequested && QueuedQueries.TryDequeue(out iq)) { ProcessInfoQuery(xml, iq); } canceltoken.ThrowIfCancellationRequested(); }