summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj@nicesj.com>2017-09-07 13:21:41 +0900
committerSung-jae Park <nicesj@nicesj.com>2017-09-07 13:21:41 +0900
commitb09929ea4b3627cccf59f8a80e8e7946ce88e4fe (patch)
tree88595320f8b278cace80cdbf7459c9abec65158f
parent8ad997d013a0444f5f70c754a7537bbe31e61145 (diff)
downloadmediahub-b09929ea4b3627cccf59f8a80e8e7946ce88e4fe.tar.gz
mediahub-b09929ea4b3627cccf59f8a80e8e7946ce88e4fe.tar.bz2
mediahub-b09929ea4b3627cccf59f8a80e8e7946ce88e4fe.zip
The async method should run its code in a task.
The task will run in the different thread. Change-Id: I4b0b0340158017ecf1f68d901b361361fe21a889 Signed-off-by: Sung-jae Park <nicesj@nicesj.com>
-rwxr-xr-xTVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs130
1 files changed, 66 insertions, 64 deletions
diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs
index 692ec9a..2515268 100755
--- a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs
+++ b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs
@@ -311,9 +311,11 @@ namespace TVMediaHub.Tizen.Models
foreach (MediaInfo mediaInformation in mediaInformationList)
{
- var mediaInformationEx = new MediaInformationEx();
+ var mediaInformationEx = new MediaInformationEx
+ {
+ MediaContentInformation = mediaInformation
+ };
- mediaInformationEx.MediaContentInformation = mediaInformation;
CheckUnavailableContent(mediaInformationEx);
mediaInformationExList.Add(mediaInformationEx);
}
@@ -357,83 +359,83 @@ namespace TVMediaHub.Tizen.Models
/// <param name="offset">The start position of the given filter Starting from zero</param>
/// <param name="count">The number of items to be searched with respect to the offset</param>
/// <returns>A list of media informations</returns>
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task<IEnumerable<MediaInformationEx>> ReadWithoutGroupAsync(SortOption sortOption, string storageId = null, int offset = -1, int count = -1)
-#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
- // Makes Content Filter by arguments
- var selectArguments = new SelectArguments();
+ return await Task.Run(() => {
+ // Makes Content Filter by arguments
+ var selectArguments = new SelectArguments();
- switch (sortOption)
- {
- case SortOption.Title:
- selectArguments.SortOrder = "MEDIA_DISPLAY_NAME";
- break;
- case SortOption.Date:
- selectArguments.SortOrder = "MEDIA_RECORDED_DATE";
- break;
- case SortOption.Genre:
- selectArguments.SortOrder = "MEDIA_GENRE";
- break;
- case SortOption.Type:
- selectArguments.SortOrder = "MEDIA_TYPE";
- break;
- case SortOption.Album:
- selectArguments.SortOrder = "MEDIA_ALBUM";
- break;
- case SortOption.Artist:
- selectArguments.SortOrder = "MEDIA_ARTIST";
- break;
- default:
- throw new System.ArgumentException("Invalid sorting option.");
- }
+ switch (sortOption)
+ {
+ case SortOption.Title:
+ selectArguments.SortOrder = "MEDIA_DISPLAY_NAME";
+ break;
+ case SortOption.Date:
+ selectArguments.SortOrder = "MEDIA_RECORDED_DATE";
+ break;
+ case SortOption.Genre:
+ selectArguments.SortOrder = "MEDIA_GENRE";
+ break;
+ case SortOption.Type:
+ selectArguments.SortOrder = "MEDIA_TYPE";
+ break;
+ case SortOption.Album:
+ selectArguments.SortOrder = "MEDIA_ALBUM";
+ break;
+ case SortOption.Artist:
+ selectArguments.SortOrder = "MEDIA_ARTIST";
+ break;
+ default:
+ throw new System.ArgumentException("Invalid sorting option.");
+ }
- if (offset >= 0)
- {
- selectArguments.StartRowIndex = offset;
- }
+ if (offset >= 0)
+ {
+ selectArguments.StartRowIndex = offset;
+ }
- if (count >= 0)
- {
- selectArguments.TotalRowCount = count;
- }
+ if (count >= 0)
+ {
+ selectArguments.TotalRowCount = count;
+ }
- if (storageId != null)
- {
- selectArguments.StorageId = storageId;
- }
+ if (storageId != null)
+ {
+ selectArguments.StorageId = storageId;
+ }
- selectArguments.FilterExpression = GetConditionStringForSelection();
+ selectArguments.FilterExpression = GetConditionStringForSelection();
- // Executes the 'select' query
- List<MediaInfo> mediaInformationList = new List<MediaInfo>();
- List<MediaInformationEx> mediaInformationExList = new List<MediaInformationEx>();
- try
- {
+ // Executes the 'select' query
+ List<MediaInfo> mediaInformationList = new List<MediaInfo>();
+ List<MediaInformationEx> mediaInformationExList = new List<MediaInformationEx>();
+ try
+ {
- var reader = MediaHubImpl.GetInstance.MediaInfoCommand.SelectMedia(selectArguments);
+ var reader = MediaHubImpl.GetInstance.MediaInfoCommand.SelectMedia(selectArguments);
- while (reader.Read())
- {
- mediaInformationList.Add(reader.Current);
- }
+ while (reader.Read())
+ {
+ mediaInformationList.Add(reader.Current);
+ }
- foreach (MediaInfo mediaInformation in mediaInformationList)
- {
- var mediaInformationEx = new MediaInformationEx();
+ foreach (MediaInfo mediaInformation in mediaInformationList)
+ {
+ var mediaInformationEx = new MediaInformationEx();
- mediaInformationEx.MediaContentInformation = mediaInformation;
- CheckUnavailableContent(mediaInformationEx);
- mediaInformationExList.Add(mediaInformationEx);
+ mediaInformationEx.MediaContentInformation = mediaInformation;
+ CheckUnavailableContent(mediaInformationEx);
+ mediaInformationExList.Add(mediaInformationEx);
+ }
+ }
+ catch (Exception exception)
+ {
+ DbgPort.E(exception.Message);
}
- }
- catch (Exception exception)
- {
- DbgPort.E(exception.Message);
- }
- return mediaInformationExList;
+ return mediaInformationExList;
+ });
}
/// <summary>