public override string ToString()
 {
     return
         (typeof(MirroringException).FullName + ": " + Message + Environment.NewLine +
          StackTrace + Environment.NewLine +
          string.Join(Environment.NewLine, InnerExceptions.Select(exception => Environment.NewLine + "---> " + exception.ToString())));
 }
Ejemplo n.º 2
0
        public static Task <int> Get_Task_TResult()
        {
            var task = Task.Run(() => { Thread.Sleep(1_000); return(263_414_974); });

            if (task.IsCompletedSuccessfully)
            {
                Console.WriteLine(task.Result);
            }

            if (task.IsFaulted)
            {
                Console.WriteLine(task.Exception !.InnerExceptions.Select(e => e.Message));
            }

            return(task);
        }
Ejemplo n.º 3
0
        internal void DataflowBlockCompleted(IDataflowBlock block)
        {
            Debug.Assert(block != null, "Block needed for the ETW event.");
            if (IsEnabled(EventLevel.Informational, ALL_KEYWORDS))
            {
                Task?completionTask   = Common.GetPotentiallyNotSupportedCompletionTask(block);
                bool blockIsCompleted = completionTask != null && completionTask.IsCompleted;
                Debug.Assert(blockIsCompleted, "Block must be completed for this event to be valid.");
                if (blockIsCompleted)
                {
                    var    reason        = (BlockCompletionReason)completionTask !.Status;
                    string exceptionData = string.Empty;

                    if (completionTask.IsFaulted)
                    {
                        try { exceptionData = string.Join(Environment.NewLine, completionTask.Exception !.InnerExceptions.Select(e => e.ToString())); }
                        catch { }
                    }

                    DataflowBlockCompleted(Common.GetBlockId(block), reason, exceptionData);
                }
            }
        }