/// <summary> /// Wraps a RemoteTask with an awaitable Task that exists within this AppDomain /// </summary> /// <param name="remoteTask">The remote task to wrap</param> /// <returns>A task that will reflect the status of the RemoteTask</returns> /// <remarks>Beware of unloading the target AppDomain in a continuation of this Task, as it's likely running with the AppDomain in the stack, causing a strange ThreadAbortException</remarks> public static Task ToTask(this RemoteTask remoteTask) => RemoteTask.CreateTask(remoteTask);
/// <summary> /// Wraps a RemoteTask with an awaitable Task that exists within this AppDomain /// </summary> /// <param name="remoteTask">The remote task to wrap</param> /// <returns>A task that will reflect the status of the RemoteTask</returns> /// <remarks>Beware of unloading the target AppDomain in a continuation of this Task, as it's likely running with the AppDomain in the stack, causing a strange ThreadAbortException</remarks> public static Task ToTask <TResult>(this RemoteTask <TResult> remoteTask) => RemoteTask <TResult> .CreateTask(remoteTask);
/// <summary> /// Allows awaiting of a RemoteTask from another AppDomain /// </summary> /// <param name="remoteTask">The remote task to await</param> /// <returns>A task awaiter that can be used to await the remote task</returns> /// <remarks>Beware of unloading the target AppDomain in a continuation of this Task, as it's likely running with the AppDomain in the stack, causing a strange ThreadAbortException</remarks> public static TaskAwaiter <TResult> GetAwaiter <TResult>(this RemoteTask <TResult> remoteTask) => // This is an extension method so the code runs in the calling AppDomain RemoteTask <TResult> .CreateTask(remoteTask).GetAwaiter();