예제 #1
0
        private void html_DownloadAsyncCompleted(DownloadClient <XDocument> sender, DownloadCompletedEventArgs <XDocument> e)
        {
            sender.AsyncDownloadCompleted -= this.html_DownloadAsyncCompleted;
            AsyncArgs args = (AsyncArgs)e.UserArgs;

            this.ConvertHtml(e.Response.Result, args);
            this.UploadAsync2(args);
        }
 private void AsyncDownload_Completed(TimeoutWebClient <T> sender, StreamDownloadCompletedEventArgs <T> e)
 {
     using (TimeoutWebClient <T> snd = sender)
     {
         snd.AsyncDownloadCompleted -= this.AsyncDownload_Completed;
         if (mWebClients.Contains(sender))
         {
             mWebClients.Remove(sender);
         }
         using (System.IO.Stream stream = (e.Response.Result != null ? e.Response.Result : new System.IO.MemoryStream()))
         {
             ConnectionInfo conn = e.Response.Connection;
             T result            = default(T);
             try
             {
                 result = this.ConvertResult(e.Response.Connection, stream, e.UserSettings);
             }
             catch (Exception ex)
             {
                 conn = new ConnectionInfo(new ConversionException("An exception was thrown during result conversion process. See InnerException for more details.", ex), conn.Timeout, conn.SizeInBytes, conn.StartTime, conn.EndTime);
             }
             finally
             {
                 Response <T> resp = this.ConvertResponse(new DefaultResponse <T>(conn, result));
                 DownloadCompletedEventArgs <T> args = this.ConvertDownloadCompletedEventArgs(new DefaultDownloadCompletedEventArgs <T>(e.UserArgs, resp, e.UserSettings));
                 if (args != null && (AsyncDownloadCompleted != null || AsyncDownloadCompletedEvent != null))
                 {
                     AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(this);
                     if (AsyncDownloadCompleted != null)
                     {
                         asyncOp.Post(new SendOrPostCallback(delegate(object obj) { AsyncDownloadCompleted(this, (DownloadCompletedEventArgs <T>)obj); }), args);
                     }
                     if (AsyncDownloadCompletedEvent != null)
                     {
                         asyncOp.Post(new SendOrPostCallback(delegate(object obj) { AsyncDownloadCompletedEvent(this, (IDownloadCompletedEventArgs)obj); }), args);
                     }
                 }
             }
         }
     }
 }
예제 #3
0
        private void dl_DownloadAsyncCompleted(DownloadClient <System.IO.Stream> sender, DownloadCompletedEventArgs <System.IO.Stream> e)
        {
            sender.AsyncDownloadCompleted -= this.dl_DownloadAsyncCompleted;
            XDocument doc = null;

            if (e.Response.Result != null)
            {
                doc = MyHelper.ParseXmlDocument(e.Response.Result);
            }
            if (this.AsyncUploadCompleted != null)
            {
                this.AsyncUploadCompleted(this, ((DefaultDownloadCompletedEventArgs <System.IO.Stream>)e).CreateNew(doc));
            }
        }