private async Task ReloadJavaScriptInProxyMode(Action dismissProgress, CancellationToken token)
        {
            try
            {
                await _devServerHelper.LaunchDevToolsAsync(token).ConfigureAwait(true);

                var factory = new Func <IJavaScriptExecutor>(() =>
                {
                    var executor = new WebSocketJavaScriptExecutor();
                    executor.ConnectAsync(_devServerHelper.WebsocketProxyUrl, token).Wait();
                    return(executor);
                });

                _reactInstanceCommandsHandler.OnReloadWithJavaScriptDebugger(factory);
                dismissProgress();
            }
            catch (DebugServerException ex)
            {
                dismissProgress();
                ShowNewNativeError(ex.Message, ex);
            }
            catch (Exception ex)
            {
                dismissProgress();
                ShowNewNativeError(
                    "Unable to download JS bundle. Did you forget to " +
                    "start the development server or connect your device?",
                    ex);
            }
        }
        private async Task <ReactContext> ReloadJavaScriptInProxyModeAsync(CancellationToken token)
        {
            var webSocketExecutor = default(WebSocketJavaScriptExecutor);

            try
            {
                var progressDialog = CreateProgressDialog("Connecting to remote debugger.");
                var dismissed      = await RunWithProgressAsync(
                    async progressToken =>
                {
                    await _devServerHelper.LaunchDevToolsAsync(progressToken).ConfigureAwait(false);
                    webSocketExecutor = new WebSocketJavaScriptExecutor();
                    await webSocketExecutor.ConnectAsync(_devServerHelper.WebsocketProxyUrl, progressToken).ConfigureAwait(false);
                },
                    progressDialog,
                    token);
            }
            catch (OperationCanceledException)
                when(token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }
            catch (DebugServerException ex)
            {
                ShowNewNativeError(ex.Message, ex);
                return(null);
            }
            catch (Exception ex)
            {
                ShowNewNativeError(
                    "Unable to connect to remote debugger. Did you forget " +
                    "to start the development server or connect your device?",
                    ex);
                return(null);
            }

            return(await _reactInstanceCommandsHandler.CreateReactContextWithRemoteDebuggerAsync(() => webSocketExecutor, token));
        }
        private async Task ReloadJavaScriptInProxyMode(Action dismissProgress, CancellationToken token)
        {
            try
            {
                await _devServerHelper.LaunchDevToolsAsync(token).ConfigureAwait(true);
                var factory = new Func<IJavaScriptExecutor>(() =>
                {
                    var executor = new WebSocketJavaScriptExecutor();
                    executor.ConnectAsync(_devServerHelper.WebsocketProxyUrl, token).Wait();
                    return executor;
                });

                _reactInstanceCommandsHandler.OnReloadWithJavaScriptDebugger(factory);
                dismissProgress();
            }
            catch (DebugServerException ex)
            {
                dismissProgress();
                ShowNewNativeError(ex.Message, ex);
            }
            catch (Exception ex)
            {
                dismissProgress();
                ShowNewNativeError(
                    "Unable to download JS bundle. Did you forget to " +
                    "start the development server or connect your device?",
                    ex);
            }
        }