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(); }