コード例 #1
0
        static void Main(string[] args)
        {
            ThreadLogger logger = new ThreadLogger(new ConsoleLogWriter());

            logger.LogMethodNumber = 4;
            var test = new AATest(logger);

            test.UseInnerLogMethodNames = true;

            // WTF with this execution? See: https://habrahabr.ru/post/232169/ and https://msdn.microsoft.com/en-us/magazine/gg598924.aspx
            test.Execute();

            Console.WriteLine("Press any key to continue . . .");
            Console.ReadKey();
        }
コード例 #2
0
        private static void StartWithContext()
        {
            Console.WriteLine($"2Has SynchronizationContext? {SynchronizationContext.Current != null}");
            using (new DummyForm()) {
                //SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
                Console.WriteLine($"3Has SynchronizationContext? {SynchronizationContext.Current != null}");

                ThreadLogger logger = new ThreadLogger(new ConsoleLogWriter());
                logger.LogMethodNumber = 4;
                var test = new AATest(logger);
                test.UseInnerLogMethodNames = true;

                // WTF with this execution? See: https://habrahabr.ru/post/232169/ and https://msdn.microsoft.com/en-us/magazine/gg598924.aspx
                test.Execute();
                //new Thread(StartWithContext).Start(SynchronizationContext.Current);

                Console.WriteLine("Worker thread exited.");
            }
            Console.WriteLine($"4Has SynchronizationContext? {SynchronizationContext.Current != null}");
        }