本文整理汇总了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);
}
}
示例2: Build
public DecisionArgs Build(AsyncCompletedEventArgs eventArgs)
{
return new DecisionArgs
{
EventArgsOfWebClient = eventArgs
};
}
示例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);
}
}
示例4: ClientDownloadFileCompleted
private void ClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
m_downloaded = true;
if (e.Cancelled)
m_error = true;
Program.Frm.SetProgress(100);
}
示例5: HasError
protected bool HasError(AsyncCompletedEventArgs args)
{
var hasError = args.Error != null;
if (hasError)
OnNewSystemMessage(args.Error.Message);
return hasError;
}
示例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();
}
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}
}
}
示例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);
}
示例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);
}
}