Repository: files-community/Files
File: src/Files.App/Utils/Cloud/CloudDrivesManager.cs (C#)

Code before:
					
					_ = MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => cloudProviderItem.UpdatePropertiesAsync());
				}
				catch (FileNotFoundException ex)
				{
					_logger?.LogInformation(ex, "Failed to find the cloud folder");
				}
				catch (UnauthorizedAccessException ex)
				{
					_logger?.LogInformation(ex, " Failed to access the cloud folder");
				}
				catch (Exception ex)
				{
					_logger?.LogWarning(ex, "Cloud provider local folder couldn't be found");
				}

				cloudProviderItem.MenuOptions = new ContextMenuOptions()
				{
					IsLocationItem = true,
					ShowEjectDevice = cloudProviderItem.IsRemovable,
					ShowShellItems = true,
					ShowProperties = true,
				};

				_ = LoadIconAsync(cloudProviderItem, provider);
				lock (_Drives)
				{
					if (_Drives.Any(x => x.Path == cloudProviderItem.Path))
						continue;

					_Drives.Add(cloudProviderItem);
				}
				DataChanged?.Invoke(
					SectionType.CloudDrives,
					new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cloudProviderItem)
				);
			}
		}

		private static async Task LoadIconAsync(DriveItem cloudProviderItem, ICloudProvider provider)
		{
			try
			{
				var iconData = provider.IconData;

				if (iconData is null)
				{
					var result = await FileThumbnailHelper.GetIconAsync(
						provider.SyncFolder,
						Constants.ShellIconSizes.Small,
						false,

Review comment (performance):
For the future reference, we can leverage the Lock class for object locking.

> Beginning with .NET 9 and C# 13, lock a dedicated object instance of the [System.Threading.Lock](https://learn.microsoft.com/en-us/dotnet/api/system.threading.lock) type for best performance.
> *https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock*

Code after:

					_ = MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => cloudProviderItem.UpdatePropertiesAsync());
				}
				catch (FileNotFoundException ex)
				{
					_logger?.LogInformation(ex, "Failed to find the cloud folder");
				}
				catch (UnauthorizedAccessException ex)
				{
					_logger?.LogInformation(ex, " Failed to access the cloud folder");
				}
				catch (Exception ex)
				{
					_logger?.LogWarning(ex, "Cloud provider local folder couldn't be found");
				}

				cloudProviderItem.MenuOptions = new ContextMenuOptions()
				{
					IsLocationItem = true,
					ShowEjectDevice = cloudProviderItem.IsRemovable,
					ShowShellItems = true,
					ShowProperties = true,
				};

				_ = LoadIconAsync(cloudProviderItem, provider);
				lock (_Drives)
				{
					if (_Drives.Any(x => x.Path == cloudProviderItem.Path))
						continue;

					_Drives.Add(cloudProviderItem);
				}
				DataChanged?.Invoke(
					SectionType.CloudDrives,
					new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cloudProviderItem)
				);
			}
		}

		private static async Task LoadIconAsync(DriveItem cloudProviderItem, ICloudProvider provider)
		{
			try
			{
				var iconData = provider.IconData;

				if (iconData is null)
				{
					var result = await FileThumbnailHelper.GetIconAsync(
						provider.SyncFolder,
						Constants.ShellIconSizes.Small,
						false,