Skip to content

Commit

Permalink
Update FileSizeCalculator.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored Oct 8, 2024
1 parent ad153fa commit fdfb696
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Files.App/Utils/Storage/Operations/FileSizeCalculator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Files Community
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using System.Collections.Concurrent;
Expand All @@ -25,13 +25,16 @@ public FileSizeCalculator(params string[] paths)

public async Task ComputeSizeAsync(CancellationToken cancellationToken = default)
{
await Parallel.ForEachAsync(_paths, cancellationToken, async (path, token) => await Task.Factory.StartNew(() =>
{
ComputeSizeRecursively(path, token);
},
token,
TaskCreationOptions.LongRunning,
TaskScheduler.Default));
await Parallel.ForEachAsync(
_paths,
cancellationToken,
async (path, token) => await Task.Factory.StartNew(() =>
{
ComputeSizeRecursively(path, token);
},
token,
TaskCreationOptions.LongRunning,
TaskScheduler.Default));

unsafe void ComputeSizeRecursively(string path, CancellationToken token)
{
Expand Down

0 comments on commit fdfb696

Please sign in to comment.