Beispiel #1
0
        internal IEnumerable <TObject> SerialStreamObjectsInternal <TObject, TParam>(StreamManager <TObject, TParam> manager)
            where TParam : PageableParameters, IXmlParameters
        {
            Debug.WriteLine("Streaming objects serially");

            if (manager.DirectCall)
            {
                prtgClient.Log("Preparing to serially stream objects", LogLevel.Trace);
            }

            manager.InitializeRequest();

            do
            {
                var response = manager.GetObjects();

                manager.UpdateTotals(response.Item2);

                if (manager.StreamEnded(response.Item1))
                {
                    prtgClient.Log($"No records were returned. Stream ended at request for record {manager.RequestIndex}/{manager.EndIndex}", LogLevel.Trace);
                    break;
                }

                foreach (var obj in response.Item1)
                {
                    yield return(obj);
                }

                manager.UpdateRequestIndex();
            } while (manager.RequestIndex < manager.EndIndex);
        }
Beispiel #2
0
        internal IEnumerable <TObject> StreamObjectsInternal <TObject, TParam>(StreamManager <TObject, TParam> manager)
            where TParam : PageableParameters, IXmlParameters
        {
            Debug.WriteLine("Streaming objects in parallel");

            if (manager.DirectCall)
            {
                prtgClient.Log("Preparing to stream objects", LogLevel.Trace);
            }

            var tasks = new List <Task <List <TObject> > >();

            manager.InitializeRequest();

            for (; manager.RequestIndex < manager.EndIndex;)
            {
                tasks.Add(manager.GetObjectsAsync());

                manager.UpdateRequestIndex();
            }

            var result = new ParallelObjectGenerator <List <TObject> >(tasks.WhenAnyForAll()).SelectMany(m => m);

            return(result);
        }