예제 #1
0
        private static async Task FeedStandardInputAsync(DetouredProcess detouredProcess, TextReader reader, TaskSourceSlim <bool> stdInTcs)
        {
            try
            {
                // We always have a redirected handle, and we always close it eventually (even if we have no actual input to feed)
                if (reader != null)
                {
                    while (true)
                    {
                        string line = await reader.ReadLineAsync();

                        if (line == null)
                        {
                            break;
                        }

                        await detouredProcess.WriteStandardInputLineAsync(line);
                    }
                }

                detouredProcess.CloseStandardInput();
                stdInTcs.TrySetResult(true);
            }
            catch (Exception e)
            {
                stdInTcs.TrySetException(e);
            }
        }
예제 #2
0
        /// <summary>
        /// Explicitly faults this block.  The fault is propagated to the <see cref="TargetBlock"/>,
        /// if so has been requested in the <see cref="LinkTo"/> method.
        /// </summary>
        public void Fault(Exception e)
        {
            var eAsAggregateException = e as AggregateException;
            var exception             = eAsAggregateException != null ? eAsAggregateException.InnerException : e;

            if (m_stopTask.TrySetException(exception))
            {
                Verbose("Faulting completion: {0}", e);
            }
        }
예제 #3
0
 public void SetFailure(Exception exception)
 {
     FinalTaskResult.TrySetException(exception);
 }