Add await and make cancel async
This commit is contained in:
parent
c0ef3ccbea
commit
0ff8da2cf0
@ -10,12 +10,12 @@ namespace LibationWinForms
|
|||||||
private void Configure_Liberate() { }
|
private void Configure_Liberate() { }
|
||||||
|
|
||||||
//GetLibrary_Flat_NoTracking() may take a long time on a hugh library. so run in new thread
|
//GetLibrary_Flat_NoTracking() may take a long time on a hugh library. so run in new thread
|
||||||
private void beginBookBackupsToolStripMenuItem_Click(object sender, EventArgs e)
|
private async void beginBookBackupsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
=> Task.Run(() => processBookQueue1.AddDownloadDecrypt(ApplicationServices.DbContexts.GetLibrary_Flat_NoTracking()
|
=> await Task.Run(() => processBookQueue1.AddDownloadDecrypt(ApplicationServices.DbContexts.GetLibrary_Flat_NoTracking()
|
||||||
.Where(lb => lb.Book.UserDefinedItem.PdfStatus is DataLayer.LiberatedStatus.NotLiberated || lb.Book.UserDefinedItem.BookStatus is DataLayer.LiberatedStatus.NotLiberated)));
|
.Where(lb => lb.Book.UserDefinedItem.PdfStatus is DataLayer.LiberatedStatus.NotLiberated || lb.Book.UserDefinedItem.BookStatus is DataLayer.LiberatedStatus.NotLiberated)));
|
||||||
|
|
||||||
private void beginPdfBackupsToolStripMenuItem_Click(object sender, EventArgs e)
|
private async void beginPdfBackupsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
=> Task.Run(() => processBookQueue1.AddDownloadPdf(ApplicationServices.DbContexts.GetLibrary_Flat_NoTracking()
|
=> await Task.Run(() => processBookQueue1.AddDownloadPdf(ApplicationServices.DbContexts.GetLibrary_Flat_NoTracking()
|
||||||
.Where(lb => lb.Book.UserDefinedItem.PdfStatus is DataLayer.LiberatedStatus.NotLiberated)));
|
.Where(lb => lb.Book.UserDefinedItem.PdfStatus is DataLayer.LiberatedStatus.NotLiberated)));
|
||||||
|
|
||||||
private async void convertAllM4bToMp3ToolStripMenuItem_Click(object sender, EventArgs e)
|
private async void convertAllM4bToMp3ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|||||||
@ -139,15 +139,14 @@ namespace LibationWinForms.ProcessQueue
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel()
|
public async Task Cancel()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (CurrentProcessable is AudioDecodable audioDecodable)
|
if (CurrentProcessable is AudioDecodable audioDecodable)
|
||||||
{
|
{
|
||||||
//There's some threadding bug that causes this to hang if executed synchronously.
|
//There's some threadding bug that causes this to hang if executed synchronously.
|
||||||
Task.Run(audioDecodable.Cancel);
|
await Task.Run(audioDecodable.Cancel);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -301,12 +301,12 @@ namespace LibationWinForms.ProcessQueue
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="queueIndex">index of the <see cref="ProcessBook"/> within <see cref="Queue"/></param>
|
/// <param name="queueIndex">index of the <see cref="ProcessBook"/> within <see cref="Queue"/></param>
|
||||||
/// <param name="panelClicked">The clicked control to update</param>
|
/// <param name="panelClicked">The clicked control to update</param>
|
||||||
private void VirtualFlowControl2_ButtonClicked(int queueIndex, string buttonName, ProcessBookControl panelClicked)
|
private async void VirtualFlowControl2_ButtonClicked(int queueIndex, string buttonName, ProcessBookControl panelClicked)
|
||||||
{
|
{
|
||||||
ProcessBook item = Queue[queueIndex];
|
ProcessBook item = Queue[queueIndex];
|
||||||
if (buttonName == nameof(panelClicked.cancelBtn))
|
if (buttonName == nameof(panelClicked.cancelBtn))
|
||||||
{
|
{
|
||||||
item.Cancel();
|
await item.Cancel();
|
||||||
Queue.RemoveQueued(item);
|
Queue.RemoveQueued(item);
|
||||||
virtualFlowControl2.VirtualControlCount = Queue.Count;
|
virtualFlowControl2.VirtualControlCount = Queue.Count;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user