private async Task Connect(
            string application,
            string executable,
            Version version,
            string hive,
            CancellationToken cancel
        ) {
            Close();

            Internal.VisualStudio ide = null;
            try {
                ide = await Internal.VisualStudio.LaunchAsync(application, executable, version, hive, cancel);

                var p = Process.GetProcessById(ide.ProcessId);
                string url = string.Format(
                    "ipc://{0}/{1}",
                    Internal.VSTestHostPackage.GetChannelName(Process.GetProcessById(ide.ProcessId)),
                    TesteeTestAdapter.Url
                );

                _remote = (TesteeTestAdapter)RemotingServices.Connect(typeof(TesteeTestAdapter), url);

                _ide = ide;
                ide = null;
            } finally {
                if (ide != null) {
                    ide.Dispose();
                }
            }
        }
        private async Task Connect(
            string application,
            string executable,
            Version version,
            string hive,
            IRunContext runContext,
            ITestElement currentTest,
            CancellationToken cancel
        ) {
            var hiveOption = string.IsNullOrEmpty(hive) ? "" : (" /rootSuffix " + hive);

            if (_ide != null &&
                _remote != null &&
                application == _currentApplication &&
                executable == _currentExecutable &&
                version == _currentVersion &&
                hive == _currentHive) {
                if (runContext != null) {
                    SendMessage(
                        runContext,
                        string.Format(Resources.VSReuseMessage, application, executable, version, hiveOption),
                        currentTest
                    );
                }
                return;
            }

            Close();

            if (runContext != null) {
                SendMessage(
                    runContext,
                    string.Format(Resources.VSLaunchMessage, application, executable, version, hiveOption),
                    currentTest
                );
            }

            Internal.VisualStudio ide = null;
            try {
                ide = await Internal.VisualStudio.LaunchAsync(application, executable, version, hive, cancel);

                var p = Process.GetProcessById(ide.ProcessId);
                var url = string.Format("ipc://{0}/{1}", VSTestHostPackage.GetChannelName(p), TesteeTestAdapter.Url);

                try {
                    _remote = (TesteeTestAdapter)RemotingServices.Connect(typeof(TesteeTestAdapter), url);
                } catch (RemotingException ex) {
                    throw new InvalidOperationException(Resources.FailedToConnect, ex);
                }

                _currentApplication = application;
                _currentExecutable = executable;
                _currentVersion = version;
                _currentHive = hive;
                _ide = ide;
                ide = null;
            } finally {
                if (ide != null) {
                    ide.Dispose();
                }
            }
        }