コード例 #1
0
        public static int Main(string[] args)
        {
            Task exceptionTask = Task.Run(ThrowExceptionTask);

            Thread.Sleep(5000);

            // Create an EventListener.
            using (SimpleEventListener myListener = new SimpleEventListener())
            {
                Thread.Sleep(5000);

                // The number below is supposed to be 2 at maximum, but in debug builds, the calls to
                // EventSource.Write() takes a lot longer than we thought, and the reflection in
                // workingset counter also adds a huge amount of time, which makes the test fail in
                // debug CIs.
                // This gives us 2 + 1 (EventSource delay) + 1 (Reflection delay) = 4 maximum possible increments
                // for the very first callback we get in EventListener. Setting the check to 4 to compensate for these.
                if (myListener.MaxIncrement > 4)
                {
                    Console.WriteLine($"Test Failed - Saw more than 3 exceptions / sec {myListener.MaxIncrement}");
                    return(1);
                }
                else
                {
                    Console.WriteLine("Test passed");
                    return(100);
                }
            }
        }
コード例 #2
0
 public static int Main(string[] args)
 {
     // Create an EventListener.
     using (SimpleEventListener myListener = new SimpleEventListener())
     {
         Thread.Sleep(3000);
         if (!myListener.SawNanFragmentation)
         {
             Console.WriteLine("Test passed");
             return(100);
         }
         else
         {
             Console.WriteLine($"Test Failed - GC fragmentation counter reported a NaN");
             return(1);
         }
     }
 }