/// <param name="mediaInformationExList">A list of MediaInformationEx</param>
/// <param name="sortOption">The current sort option</param>
/// <returns>A list of group item</returns>
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
private async Task<IEnumerable<GroupItem>> MakeGroupAsync(IEnumerable<MediaInformationEx> mediaInformationExList, SortOption sortOption)
-#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
- List<GroupItem> result = new List<GroupItem>();
- GroupItem lastGroupItem = null;
- GroupItem currentGroupItem = null;
-
- if (mediaInformationExList == null)
+ return await Task.Run(() =>
{
- DbgPort.D("MG Async");
- throw new System.ArgumentException("mediaInformationExList must not be null.");
- }
+ List<GroupItem> result = new List<GroupItem>();
+ GroupItem lastGroupItem = null;
+ GroupItem currentGroupItem = null;
- foreach (MediaInformationEx mediaInformationEx in mediaInformationExList)
- {
- var currentInformation = mediaInformationEx;
- var shortcutInfo = new MediaShortcutInfo(currentInformation);
-
- // TODO : The catch implementation should be checked once again.
- try
- {
- currentGroupItem = GetGroupItem(sortOption, currentGroupItem, mediaInformationEx);
- }
- catch (Exception e)
+ if (mediaInformationExList == null)
{
- DbgPort.E(e.Message);
- return null;
+ throw new System.ArgumentException("mediaInformationExList must not be null.");
}
- if (lastGroupItem != currentGroupItem)
+ foreach (MediaInformationEx mediaInformationEx in mediaInformationExList)
{
- result.Add(currentGroupItem);
- lastGroupItem = currentGroupItem;
- }
+ var currentInformation = mediaInformationEx;
+ var shortcutInfo = new MediaShortcutInfo(currentInformation);
- if (currentGroupItem != null)
- {
- currentGroupItem.Contents.Add(shortcutInfo);
+ // TODO : The catch implementation should be checked once again.
+ try
+ {
+ currentGroupItem = GetGroupItem(sortOption, currentGroupItem, mediaInformationEx);
+ }
+ catch (Exception e)
+ {
+ DbgPort.E(e.Message);
+ return null;
+ }
+
+ if (lastGroupItem != currentGroupItem)
+ {
+ result.Add(currentGroupItem);
+ lastGroupItem = currentGroupItem;
+ }
+
+ if (currentGroupItem != null)
+ {
+ currentGroupItem.Contents.Add(shortcutInfo);
+ }
}
- }
- return result;
+ return result;
+ });
}
/// <summary>