Exemplo n.º 1
0
        public static Task GetTask(this RemoteTask remoteTask)
        {
            AsyncManualResetEvent taskCompletedEvent = new AsyncManualResetEvent();

            void Signal(Exception ex)
            {
                if (ex != null)
                {
                    throw ex;
                }

                taskCompletedEvent.Set();
            }

            async Task WaitForSignal()
            {
                await taskCompletedEvent.WaitAsync();
            }

            remoteTask.SetCallback(new ActionProxy <Exception>(Signal));

            return(Task.Run(WaitForSignal));
        }
Exemplo n.º 2
0
 public static TaskAwaiter GetAwaiter(this RemoteTask remoteTask)
 {
     return(remoteTask.GetTask().GetAwaiter());
 }
Exemplo n.º 3
0
 public static T GetResult <T>(this RemoteTask <T> remoteTask)
 {
     return(remoteTask.GetAwaiter().GetResult());
 }
Exemplo n.º 4
0
 public static TaskAwaiter <T> GetAwaiter <T>(this RemoteTask <T> remoteTask)
 {
     return(remoteTask.GetTask().GetAwaiter());
 }