Do library scan on background thread
This commit is contained in:
parent
1fdcea929f
commit
890747a902
@ -202,7 +202,7 @@ namespace LibationAvalonia.ViewModels
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var (totalProcessed, newAdded) = await LibraryCommands.ImportAccountAsync(accounts);
|
var (totalProcessed, newAdded) = await Task.Run(() => LibraryCommands.ImportAccountAsync(accounts));
|
||||||
|
|
||||||
// this is here instead of ScanEnd so that the following is only possible when it's user-initiated, not automatic loop
|
// this is here instead of ScanEnd so that the following is only possible when it's user-initiated, not automatic loop
|
||||||
if (Configuration.Instance.ShowImportedStats && newAdded > 0)
|
if (Configuration.Instance.ShowImportedStats && newAdded > 0)
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using LibationFileManager;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
namespace LibationAvalonia.ViewModels
|
namespace LibationAvalonia.ViewModels
|
||||||
@ -27,7 +28,7 @@ namespace LibationAvalonia.ViewModels
|
|||||||
// in autoScan, new books SHALL NOT show dialog
|
// in autoScan, new books SHALL NOT show dialog
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await LibraryCommands.ImportAccountAsync(accounts);
|
await Task.Run(() => LibraryCommands.ImportAccountAsync(accounts));
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -32,11 +32,7 @@ namespace LibationWinForms
|
|||||||
// in autoScan, new books SHALL NOT show dialog
|
// in autoScan, new books SHALL NOT show dialog
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task importAsync() => LibraryCommands.ImportAccountAsync(accounts);
|
await Task.Run(() => LibraryCommands.ImportAccountAsync(accounts));
|
||||||
if (InvokeRequired)
|
|
||||||
await Invoke(importAsync);
|
|
||||||
else
|
|
||||||
await importAsync();
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -74,7 +74,7 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var (totalProcessed, newAdded) = await LibraryCommands.ImportAccountAsync(accounts);
|
var (totalProcessed, newAdded) = await Task.Run(() => LibraryCommands.ImportAccountAsync(accounts));
|
||||||
|
|
||||||
// this is here instead of ScanEnd so that the following is only possible when it's user-initiated, not automatic loop
|
// this is here instead of ScanEnd so that the following is only possible when it's user-initiated, not automatic loop
|
||||||
if (Configuration.Instance.ShowImportedStats && newAdded > 0)
|
if (Configuration.Instance.ShowImportedStats && newAdded > 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user