当前位置: 首页>>代码示例>>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;未经允许,请勿转载。