Example #1
0
        void IPlatformAppLauncher.SetupForDebugging(out LaunchOptions result)
        {
            if (_launchOptions == null)
            {
                Debug.Fail("Why is SetupForDebugging being called before ParseLaunchOptions?");
                throw new InvalidOperationException();
            }

            ManualResetEvent doneEvent  = new ManualResetEvent(false);
            var cancellationTokenSource = new CancellationTokenSource();
            ExceptionDispatchInfo exceptionDispatchInfo = null;
            LaunchOptions         localLaunchOptions    = null;

            _waitLoop = new MICore.WaitLoop(LauncherResources.WaitDialogText);

            // Do the work on a worker thread to avoid blocking the UI. Use ThreadPool.QueueUserWorkItem instead
            // of Task.Run to avoid needing to unwrap the AggregateException.
            ThreadPool.QueueUserWorkItem((object o) =>
            {
                string launchErrorTelemetryResult = null;

                try
                {
                    localLaunchOptions         = SetupForDebuggingWorker(cancellationTokenSource.Token);
                    launchErrorTelemetryResult = "None";
                }
                catch (Exception e)
                {
                    exceptionDispatchInfo = ExceptionDispatchInfo.Capture(e);
                    if (!(e is OperationCanceledException))
                    {
                        launchErrorTelemetryResult = Telemetry.GetLaunchErrorResultValue(e);
                    }
                }

                doneEvent.Set();

                if (launchErrorTelemetryResult != null)
                {
                    Telemetry.SendLaunchError(launchErrorTelemetryResult, _targetEngine.ToString());
                }
            }
                                         );

            _waitLoop.Wait(doneEvent, cancellationTokenSource);

            if (exceptionDispatchInfo != null)
            {
                exceptionDispatchInfo.Throw();
            }
            if (localLaunchOptions == null)
            {
                Debug.Fail("No result provided? Should be impossible.");
                throw new InvalidOperationException();
            }

            result = localLaunchOptions;
        }
Example #2
0
        public async Task Initialize(MICore.WaitLoop waitLoop, CancellationToken token)
        {
            bool success = false;

            Natvis.Initialize(_launchOptions.VisualizerFile);
            int total = 1;

            await this.WaitForConsoleDebuggerInitialize(token);

            try
            {
                await this.MICommandFactory.EnableTargetAsyncOption();

                List <LaunchCommand> commands = GetInitializeCommands();

                total = commands.Count();
                var i = 0;
                foreach (var command in commands)
                {
                    token.ThrowIfCancellationRequested();
                    waitLoop.SetProgress(total, i++, command.Description);
                    if (command.IsMICommand)
                    {
                        Results results = await CmdAsync(command.CommandText, ResultClass.None);

                        if (results.ResultClass == ResultClass.error && !command.IgnoreFailures)
                        {
                            string miError = results.FindString("msg");
                            throw new UnexpectedMIResultException(command.CommandText, miError);
                        }
                    }
                    else
                    {
                        await ConsoleCmdAsync(command.CommandText);
                    }
                }


                success = true;
            }
            finally
            {
                if (!success)
                {
                    Terminate();
                }
            }
            waitLoop.SetProgress(total, total, String.Empty);
            token.ThrowIfCancellationRequested();
        }
Example #3
0
        void IPlatformAppLauncher.SetupForDebugging(out LaunchOptions result)
        {
            if (_launchOptions == null)
            {
                Debug.Fail("Why is SetupForDebugging being called before ParseLaunchOptions?");
                throw new InvalidOperationException();
            }

            ManualResetEvent doneEvent = new ManualResetEvent(false);
            var cancellationTokenSource = new CancellationTokenSource();
            ExceptionDispatchInfo exceptionDispatchInfo = null;
            LaunchOptions localLaunchOptions = null;

            _waitLoop = new MICore.WaitLoop(LauncherResources.WaitDialogText);

            // Do the work on a worker thread to avoid blocking the UI. Use ThreadPool.QueueUserWorkItem instead
            // of Task.Run to avoid needing to unwrap the AggregateException.
            ThreadPool.QueueUserWorkItem((object o) =>
                {
                    string launchErrorTelemetryResult = null;

                    try
                    {
                        localLaunchOptions = SetupForDebuggingWorker(cancellationTokenSource.Token);
                        launchErrorTelemetryResult = "None";
                    }
                    catch (Exception e)
                    {
                        exceptionDispatchInfo = ExceptionDispatchInfo.Capture(e);
                        if (!(e is OperationCanceledException))
                        {
                            launchErrorTelemetryResult = Telemetry.GetLaunchErrorResultValue(e);
                        }
                    }

                    doneEvent.Set();

                    if (launchErrorTelemetryResult != null)
                    {
                        Telemetry.SendLaunchError(launchErrorTelemetryResult);
                    }
                }
            );

            _waitLoop.Wait(doneEvent, cancellationTokenSource);

            if (exceptionDispatchInfo != null)
            {
                exceptionDispatchInfo.Throw();
            }
            if (localLaunchOptions == null)
            {
                Debug.Fail("No result provided? Should be impossible.");
                throw new InvalidOperationException();
            }

            result = localLaunchOptions;
        }