Esempio n. 1
0
 private void DestroyWebClient()
 {
     if (wc != null) {
         wc.DownloadFileCompleted -= OnDownloadFileCompletedHandler;
         wc.DownloadProgressChanged -= OnDownloadProgressChangedHandler;
         wc.ResponseReceived -= OnResponseReceivedHandler;
         wc = null;
     }
 }
Esempio n. 2
0
        private void InitWebClient()
        {
            wc = new AsyncWebClient ();

            if (localStream.Length > 0) {
                wc.Range = Convert.ToInt32 (localStream.Length);
                //Console.WriteLine ("Adding Range:  {0}", wc.Range);
            }

            wc.Timeout = (5 * 60 * 1000);
            wc.DownloadFileCompleted += OnDownloadFileCompletedHandler;
            wc.DownloadProgressChanged += OnDownloadProgressChangedHandler;
            wc.ResponseReceived += OnResponseReceivedHandler;
        }
Esempio n. 3
0
        public override void ExecuteAsync()
        {
            lock (SyncRoot) {
                SetStatus (TaskStatus.Running);

                if (mre != null) {
                    mre.Reset ();
                }
            }

            try {
                wc = new AsyncWebClient ();
                wc.Timeout = (30 * 1000); // 30 Seconds
                if (feed.LastDownloadError == FeedDownloadError.None && feed.LastDownloadTime != DateTime.MinValue) {
                    wc.IfModifiedSince = feed.LastDownloadTime.ToUniversalTime ();
                }
                wc.DownloadStringCompleted += OnDownloadDataReceived;

                feed.DownloadStatus = FeedDownloadStatus.Downloading;
                wc.DownloadStringAsync (new Uri (feed.Url));
            } catch (Exception e) {
                if (wc != null) {
                    wc.DownloadStringCompleted -= OnDownloadDataReceived;
                }

                EmitCompletionEvents (FeedDownloadError.DownloadFailed);
                Log.Error (e);
            }
        }