18
18
using System . Threading ;
19
19
using System . Threading . Tasks ;
20
20
using Windows . ApplicationModel . Core ;
21
+ using Windows . Foundation ;
21
22
using Windows . Storage ;
22
23
using Windows . Storage . FileProperties ;
23
24
using Windows . Storage . Search ;
@@ -397,7 +398,7 @@ public void CancelLoadAndClearFiles()
397
398
{
398
399
_itemQueryResult . ContentsChanged -= FileContentsChanged ;
399
400
}
400
-
401
+ watchedItemsOperation . Cancel ( ) ;
401
402
App . CurrentInstance . NavigationToolbar . CanGoBack = true ;
402
403
App . CurrentInstance . NavigationToolbar . CanGoForward = true ;
403
404
App . CurrentInstance . NavigationToolbar . CanNavigateToParent = true ;
@@ -609,7 +610,7 @@ public async void LoadExtendedItemProperties(ListedItem item, uint thumbnailSize
609
610
{
610
611
matchingItem . FolderRelativeId = matchingStorageItem . FolderRelativeId ;
611
612
matchingItem . ItemType = matchingStorageItem . DisplayType ;
612
- using ( var Thumbnail = await matchingStorageItem . GetThumbnailAsync ( ThumbnailMode . SingleItem , thumbnailSize , ThumbnailOptions . ReturnOnlyIfCached ) )
613
+ using ( var Thumbnail = await matchingStorageItem . GetThumbnailAsync ( ThumbnailMode . SingleItem , thumbnailSize , ThumbnailOptions . UseCurrentScale ) )
613
614
{
614
615
if ( Thumbnail != null )
615
616
{
@@ -655,6 +656,8 @@ public async Task RefreshItems()
655
656
await AddItemsToCollectionAsync ( WorkingDirectory ) ;
656
657
}
657
658
public IReadOnlyList < IStorageItem > watchedItems = null ;
659
+ private IAsyncOperation < IReadOnlyList < IStorageItem > > watchedItemsOperation ;
660
+
658
661
public async Task RapidAddItemsToCollectionAsync ( string path )
659
662
{
660
663
App . CurrentInstance . NavigationToolbar . CanRefresh = false ;
@@ -724,7 +727,7 @@ public async Task RapidAddItemsToCollectionAsync(string path)
724
727
FileSizeBytes = 0
725
728
} ;
726
729
727
- await Task . Run ( async ( ) =>
730
+ await Task . Run ( ( ) =>
728
731
{
729
732
var options = new QueryOptions ( )
730
733
{
@@ -735,10 +738,9 @@ await Task.Run(async () =>
735
738
options . SetThumbnailPrefetch ( ThumbnailMode . ListView , 0 , ThumbnailOptions . ReturnOnlyIfCached ) ;
736
739
_itemQueryResult = _rootFolder . CreateItemQueryWithOptions ( options ) ;
737
740
_itemQueryResult . ContentsChanged += FileContentsChanged ;
738
- watchedItems = await _itemQueryResult . GetItemsAsync ( ) ;
739
-
741
+ watchedItemsOperation = _itemQueryResult . GetItemsAsync ( ) ;
742
+ watchedItemsOperation . Completed += delegate { watchedItems = watchedItemsOperation . GetResults ( ) ; } ;
740
743
} ) ;
741
-
742
744
}
743
745
catch ( UnauthorizedAccessException )
744
746
{
0 commit comments