Beispiel #1
0
        static TestBase()
        {
            TaskScheduler.UnobservedTaskException += (sender, args) =>
            {
                Console.WriteLine("Unobserved: " + args.Exception);
                args.SetObserved();
#if NETCOREAPP1_0
                if (IgnorableExceptionPredicates.Any(predicate => predicate(args.Exception.InnerException)))
                {
                    return;
                }
#endif
                lock (sharedFailCount)
                {
                    if (sharedFailCount != null)
                    {
                        sharedFailCount.Value++;
                    }
                }
                lock (backgroundExceptions)
                {
                    backgroundExceptions.Add(args.Exception.ToString());
                }
            };
        }
        static TestBase()
        {
            TaskScheduler.UnobservedTaskException += (sender, args) =>
            {
                Console.WriteLine("Unobserved: " + args.Exception);
                args.SetObserved();
#if CORE_CLR
                if (IgnorableExceptionPredicates.Any(predicate => predicate(args.Exception.InnerException)))
                {
                    return;
                }
#endif
                Interlocked.Increment(ref sharedFailCount);
                lock (backgroundExceptions)
                {
                    backgroundExceptions.Add(args.Exception.ToString());
                }
            };
        }