Exemple #1
0
        public static async void Init()
        {
            var queue = new RequestQueue();

            var google = new Uri("http://www.google.com/");
            var songkick = new Uri("http://api.songkick.com/api/3.0/events.json?location=clientip&apikey=G2KCF6q91g23Q6Zh");

            Parallel.For(1, 16, async x =>
            {
                var uri = x % 2 == 0 ?
                    google :
                    songkick;

                var request = new StringRequest
                {
                    Uri = uri,
                };
                queue.Add(request);

                try
                {
                    var result = await request.GetResultAsync();
                    Console.WriteLine("received response: {0}", result.Substring(0, 40));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("handled exception: {0}", ex);
                }
            });
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var queue = new RequestQueue();

            var google = new Uri("http://www.google.com");
            var yahoo = new Uri("http://www.yahoo.com");
            var songkick = new Uri("http://api.songkick.com/api/3.0/events.json?location=clientip&apikey=G2KCF6q91g23Q6Zh");

            for (var x = 1; x <= 16; x++)
            {
                Thread.Sleep(200);

                var request_number = x;
                var uri = x % 2 == 0 ?
                    google :
                    songkick;

                var request = new StringRequest
                {
                    Uri = uri,
                    OnResponse = response =>
                    {
                        Console.WriteLine("received response {0}, {1}", request_number, response.Substring(0, 48));
                    },
                };

                queue.Add(request);
            };

            Console.ReadLine();
        }
Exemple #3
0
        public void Finish(string marker_name)
        {
            if (RequestQueue == null)
            {
                return;
            }

            RequestQueue.Finish(this);

            AddMarker(marker_name);
            _marker_log.Finish(RequestQueue.Log, this.ToString());
        }