Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions Activout.RestClient/Helpers/Implementation/TaskConverter3.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;

namespace Activout.RestClient.Helpers.Implementation;

/*
* Convert from Task<object> to Task<T> where T is the Type
*
* Implemented by creating a TaskCompletionSource<T> and setting the result or exception
*/
public class TaskConverter3<T> : ITaskConverter
{
Expand All @@ -20,16 +17,6 @@ public object ConvertReturnType(Task<object> task)
[StackTraceHidden]
private static async Task<T> ConvertReturnTypeImpl(Task<object> task)
{
var taskCompletionSource = new TaskCompletionSource<T>();
try
{
taskCompletionSource.SetResult((T)await task);
}
catch (Exception e)
{
taskCompletionSource.SetException(e);
}

return await taskCompletionSource.Task;
return (T)await task;
}
}