Example #1
0
        private DialogAction ShowAssertDialog(AssertionViewModel vm)
        {
            using var resetEvent = new AutoResetEvent(false);
            DialogAction action = DialogAction.Ignore;
            var          t      = new Thread(() => {
                var dialog = new DebugAssertWindow(vm);
                dialog.ShowDialog();
                action = dialog.Action;
                resetEvent.Set();
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            resetEvent.WaitOne();

            return(action);
        }
Example #2
0
        private void InitWpfStack()
        {
            using var resetEvent = new AutoResetEvent(false);

            // We can't be sure that the calling thread is STA (necessary to create the Window),
            // so we'll create a thread to make sure it's compliant.
            var t = new Thread(() => {
                // create an instance of our window to make sure all the WPF tracing gets initialized
                var dialog = new DebugAssertWindow(new AssertionViewModel(string.Empty, string.Empty, string.Empty));
                resetEvent.Set();
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            resetEvent.WaitOne();
        }