Get the result of Task <T> without knowing typeof T
I am working on a C # system, and the class has one function that returns an object System.Threading.Tasks.Taskand has the System.TypeReturnType property .
When ReturnType is null, I know that the method returns a Task object. But, unfortunately, there is no way to find out if the class that implements the interface returns, Task<ReturnType>or Task<object>, and I need to get the result of this method. I think the easiest way to do this is to convert Task<T>to Task<object>so that I can get the result and process it using the type value in ReturnType.
How to convert Task<T>to Task<object>without knowing type T?
public interface ITaskFactory
{
ReadOnlyCollection<ParameterInfo> ParametersInfo { get; }
Type ReturnType { get; }
Task CreateTask (params object[] args);
}
I need to get the result returned Taskthat I got by callingCreateTask()