當前位置: 首頁>>代碼示例>>C#>>正文


C# ComponentModel.AsyncCompletedEventArgs類代碼示例

本文整理匯總了C#中System.ComponentModel.AsyncCompletedEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# AsyncCompletedEventArgs類的具體用法?C# AsyncCompletedEventArgs怎麽用?C# AsyncCompletedEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AsyncCompletedEventArgs類屬於System.ComponentModel命名空間,在下文中一共展示了AsyncCompletedEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnLoadCompleted

 protected virtual void OnLoadCompleted(AsyncCompletedEventArgs e)
 {
     if (LoadCompleted != null)
     {
         LoadCompleted(this, e);
     }
 }
開發者ID:qucc,項目名稱:ImageDownloader,代碼行數:7,代碼來源:FileDownloader.cs

示例2: Build

 public DecisionArgs Build(AsyncCompletedEventArgs eventArgs)
 {
     return new DecisionArgs
     {
         EventArgsOfWebClient = eventArgs
     };
 }
開發者ID:oxscar93,項目名稱:Projects-C-,代碼行數:7,代碼來源:DecisionsArgsBuilder.cs

示例3: _webClient_DownloadFileCompleted

 void _webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     Audio audio = e.UserState as Audio;
     string filePath = String.Format("{0}.mp3", audio.ToString());
     TagLib.File tagFile = TagLib.File.Create(filePath);
     string artistName = tagFile.Tag.FirstAlbumArtist == null ? "Unknown artist" : tagFile.Tag.FirstAlbumArtist;
     string albumName = tagFile.Tag.Album == null ? "Unknown album" : tagFile.Tag.Album;
     string title = tagFile.Tag.Title == null ? "Unknown title" : tagFile.Tag.Title;
     var artist = _artists.FirstOrDefault(g => g.Name.ToLower() == artistName.ToLower());
     if (artist == null)
     {
         artist = new Artist(artistName);
         _artists.Add(artist);
     }
     var album = artist.Albums.FirstOrDefault(g => g.Name.ToLower() == albumName.ToLower());
     if (album == null)
     {
         album = new Album(albumName);
         artist.Albums.Add(album);
     }
     var song = album.Songs.FirstOrDefault(g => g.Name.ToLower() == title.ToLower());
     if (song == null)
     {
         song = new Song(title, filePath);
         album.Songs.Add(song);
     }
 }
開發者ID:bebecap,項目名稱:VkDownloader,代碼行數:27,代碼來源:AudioWindow.cs

示例4: ClientDownloadFileCompleted

 private void ClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     m_downloaded = true;
     if (e.Cancelled)
         m_error = true;
     Program.Frm.SetProgress(100);
 }
開發者ID:Buttys,項目名稱:YgoUpdater,代碼行數:7,代碼來源:Updater.cs

示例5: HasError

 protected bool HasError(AsyncCompletedEventArgs args)
 {
     var hasError = args.Error != null;
     if (hasError)
         OnNewSystemMessage(args.Error.Message);
     return hasError;
 }
開發者ID:usemam,項目名稱:SilverlightChat,代碼行數:7,代碼來源:ChatModelBase.cs

示例6: HandleCompletion

 /// MONO completely lacks SmtpClient.SendAsync, so this is a copy -----------------------------------------------------------------------------
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tcs"></param>
 /// <param name="e"></param>
 /// <param name="handler"></param>
 /// <param name="client"></param>
 static void HandleCompletion(TaskCompletionSource<object> tcs, AsyncCompletedEventArgs e, SendCompletedEventHandler handler, SmtpClient client)
 {
     if (e.UserState == tcs)
     {
         try
         {
             client.SendCompleted -= handler;
         }
         finally
         {
             if (e.Error != null)
             {
                 tcs.TrySetException(e.Error);
             }
             else if (!e.Cancelled)
             {
                 tcs.TrySetResult(null);
             }
             else
             {
                 tcs.TrySetCanceled();
             }
         }
     }
 }
開發者ID:sfinder,項目名稱:metaexchange,代碼行數:33,代碼來源:Email.cs

示例7: client_DownloadFileCompleted

 private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     lbl_status.Text = "Status: Completed";
     Thread.Sleep(500);
     Process.Start("R2_Compiler_conf_gui.exe");
     Application.Exit();
 }
開發者ID:whit33r,項目名稱:Compile_Configuration_GUI,代碼行數:7,代碼來源:Update.cs

示例8: client_DownloadFileCompleted

        private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            string rootDir = Path.GetDirectoryName(this.FilePath);
            string unzipFolder = Path.Combine(rootDir, this.NewVersion);
            if (Directory.Exists(unzipFolder))
            {
                Directory.Delete(unzipFolder, true);
            }
            Directory.CreateDirectory(unzipFolder);
            ZipHelp.UnZip(this.FilePath, unzipFolder);

            string sourceFolder = "";
            var files = Directory.EnumerateFiles(unzipFolder, Config.MainExe, SearchOption.AllDirectories);
            if (files != null && files.Count() == 1)
            {
                var targetFileName = files.FirstOrDefault();
                sourceFolder = Path.GetDirectoryName(targetFileName);
            }

            string targetDir = Environment.CurrentDirectory;
            foreach (var process in Process.GetProcessesByName("CKGen"))
            {
                process.Kill();
            }

            RenameAllFile(targetDir);
            //copy 
            ProcessXcopy(sourceFolder, targetDir);

            Process.Start(Path.Combine(Environment.CurrentDirectory, Config.MainExe));

            this.Close();
        }
開發者ID:zhh007,項目名稱:CKGen,代碼行數:33,代碼來源:Form1.cs

示例9: BeginDownload

		public void BeginDownload(RemoteFileInfo fileInfo, string destPath)
		{
			try
			{
				var localFileInfo = new FileInfo(destPath);
				if (localFileInfo.Exists)
				{
					if (Sha1VerifyFile(destPath, fileInfo.Sha1Hash))
					{
						var newEvt = new AsyncCompletedEventArgs(null, false, null);
						DownloadFileCompleted(this, newEvt);
						return; //already have the file with correct contents on disk
					}
				}
			}
			catch (Exception ex)
			{
				var newEvt = new AsyncCompletedEventArgs(ex, false, null);
				DownloadFileCompleted(this, newEvt);
				return; //something failed when trying to hash file
			}

			if (_wc != null)
			{
				_wc.CancelAsync();
				_wc.Dispose();
				_wc = null;
			}

			_wc = new CustomWebClient(Timeout);
			_wc.DownloadProgressChanged += (sender, evt) => { DownloadProgressChanged(sender, evt); };
			_wc.DownloadFileCompleted += (sender, evt) =>
			{
				using (var wc = (WebClient) sender)
				{
					if (evt.Cancelled || evt.Error != null)
					{
						DownloadFileCompleted(sender, evt);
						return;
					}

					try
					{
						if (!Sha1VerifyFile(destPath, fileInfo.Sha1Hash))
							throw new Exception("Hash mismatch after download");
					}
					catch (Exception ex)
					{
						var newEvt = new AsyncCompletedEventArgs(ex, false, evt.UserState);
						DownloadFileCompleted(sender, newEvt);
						return;
					}

					DownloadFileCompleted(sender, evt);
				}
				_wc = null;
			};

			_wc.DownloadFileAsync(new Uri(fileInfo.Url), destPath);
		}
開發者ID:rajkosto,項目名稱:DayZeroLauncher,代碼行數:60,代碼來源:HashWebClient.cs

示例10: ClientDownloadFileCompleted

        /// <summary>
        /// Callback by the web client class when the download finish (completed or cancelled)
        /// </summary>
        void ClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            Thread.Sleep(1500);     // A short pause for a better visual flow

            inProgress.Set();
            isCompleted = !e.Cancelled;
        }
開發者ID:splintor,項目名稱:GitForce,代碼行數:10,代碼來源:FormDownload.cs

示例11: wc_DownloadFileCompleted

 void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
   if (e.Error != null || e.Cancelled)
   {
     Trace.TraceError("{0} failed {1}", Name, e.Error);
     Finish(false);
   }
   else
   {
     Trace.TraceInformation("{0} Completed - {1}", Name, Utils.PrintByteLength(Length));
     try
     {
       File.Delete(targetFilePath);
     }
     catch {}
     try
     {
       File.Move(tempFilePath, targetFilePath);
     }
     catch
     {
       Trace.TraceError("Error moving file from {0} to {0}", tempFilePath, targetFilePath);
       Finish(false);
       return;
     }
     Finish(true);
   }
 }
開發者ID:GoogleFrog,項目名稱:Zero-K-Infrastructure,代碼行數:28,代碼來源:WebFileDownload.cs

示例12: Completed2

 private void Completed2(object sender, AsyncCompletedEventArgs e)
 {
     File.Copy(savePath + "/cs_bg_champions.png", savePath + "/login.swf", true);
     //MessageBox.Show("Download completed!");
     this.Hide();
     MessageBox.Show("Download completed." + Environment.NewLine + Environment.NewLine + "To enable music, you may need to click on \"Disable Menu Animations\".", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
開發者ID:ssimunic,項目名稱:loginscreen-changer,代碼行數:7,代碼來源:Form2.cs

示例13: wc_DownloadFileCompleted

 void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error != null&&!e.Cancelled)
     {
         //下載出錯
         label2.Text = e.Error.Message;
         CancleBtn.Text = "關閉";
         //File.Delete(Application.StartupPath + "/" + DownloadInfo.FileDirectory + "/" + DownloadInfo.FileName);
     }
     else
     {
         if (!e.Cancelled)
         {
             label2.Text = "下載完成";
             CancleBtn.Text = "關閉";
             Process proc = new Process();
             proc.StartInfo.FileName = Application.StartupPath + "/" + DownloadInfo.FileDirectory + "/" + DownloadInfo.FileName;
             proc.StartInfo.Arguments = "";
             proc.Start();
             if (CloseCheckBox.Checked)
             {
                 this.Close();
             }
         }
         else
         {
             //用戶取消了下載
             File.Delete(Application.StartupPath + "/" + DownloadInfo.FileDirectory + "/" + DownloadInfo.FileName);
             this.Close();
         }
     }
 }
開發者ID:GuardAngelY,項目名稱:wowitemmaker,代碼行數:32,代碼來源:Downloader.cs

示例14: Completed

 private void Completed(object sender, AsyncCompletedEventArgs e)
 {
     progressBar.Visibility = System.Windows.Visibility.Hidden;
     Feedback.Text = "Download completed";
     Feedback.Visibility = System.Windows.Visibility.Visible;
     Process.Start(downloadedFile);
 }
開發者ID:thorthur,項目名稱:drugabuse_interface,代碼行數:7,代碼來源:HomePage.xaml.cs

示例15: DownloadFileAsync_should_be_callable_indirectly

        public void DownloadFileAsync_should_be_callable_indirectly()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var called = false;
                var notCalled = true;
                var handler = default(AsyncCompletedEventHandler);
                handler = (sender, e) => called = true;
                PULWebClient.AddDownloadFileCompletedAsyncCompletedEventHandler().Body = (@this, value) => handler += value;
                PULWebClient.RemoveDownloadFileCompletedAsyncCompletedEventHandler().Body = (@this, value) => handler -= value;
                PULWebClient.DownloadFileAsyncUri().Body = (@this, address) =>
                {
                    var e = new AsyncCompletedEventArgs(null, false, null);
                    handler(@this, e);
                };

                
                // Act
                var client = new ULWebClient();
                client.DownloadFileAsync(new Uri("http://google.co.jp/"));
                client.DownloadFileCompleted += (sender, e) => notCalled = false;

                
                // Assert
                Assert.IsTrue(called);
                Assert.IsTrue(notCalled);
            }
        }
開發者ID:umaranis,項目名稱:Prig,代碼行數:29,代碼來源:PULWebClientTest.cs


注:本文中的System.ComponentModel.AsyncCompletedEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。