internal async Task createWebView(Dictionary<string, object> options)
        {
            try
            {
            //    throw new NotImplementedException();
#if WINDOWS_WIN32_WPF
                _browserWindow.createWindow(options);
                WebBrowser webView = _browserWindow._window.webBrowser;
#elif WINDOWS_WIN32_WF
                     WebBrowser webView = new WebBrowser();       
                    _browserWindow.createWindow(options, webView);
#endif
                this.webView = webView;
                _browserWindow.webView = webView;

                string url;
                if (options.ContainsKey(NKEBrowserOptions.kPreloadURL))
                    url = (string)options[NKEBrowserOptions.kPreloadURL];
                else
                    url = NKEBrowserDefaults.kPreloadURL;

                webView.Navigate(new Uri(url));

#if WINDOWS_WIN32_WPF
                webView.Navigating += this.WebView_Navigating;
                webView.LoadCompleted += this.WebView_LoadCompleted;
#elif WINDOWS_WIN32_WF
                    webView.Navigating += this.WebView_Navigating;
                    webView.DocumentCompleted += this.WebView_DocumentCompleted;
#endif
                this.init_IPC();

                _browserWindow.context = await NKSMSWebBrowserContext.getScriptContext(_id, webView, options);

                this._type = NKEBrowserType.MSWebView.ToString();
                if (options.itemOrDefault<bool>("NKE.InstallElectro", true))
                    await Renderer.addElectro(_browserWindow.context, options);
                NKLogging.log(string.Format("+E{0} Renderer Ready", _id));

                _browserWindow.events.emit("NKE.DidFinishLoad", _id);
      
            }
            catch (Exception ex)
            {
                NKLogging.log("!Error creating browser webcontent: " + ex.Message);
                NKLogging.log(ex.StackTrace);
            }
            options = null;

        }
        internal async Task createWebView(Dictionary<string, object> options)
        {
            _browserWindow._window = await _browserWindow.createWindow(options);

            string url;
            if (options.ContainsKey(NKEBrowserOptions.kPreloadURL))
                url = (string)options[NKEBrowserOptions.kPreloadURL];
            else
                url = NKEBrowserDefaults.kPreloadURL;

            WebView webView = new WebView(WebViewExecutionMode.SeparateThread);
            this.webView = webView;
            _browserWindow.webView = webView;

            _browserWindow._window.controls.Add(webView);
            webView.Navigate(new Uri(url));
            _browserWindow.context = await NKSMSWebViewContext.getScriptContext(_id, webView, options);

            webView.NavigationStarting += WebView_NavigationStarting;
            webView.NavigationCompleted += this.WebView_NavigationCompleted;

            this.init_IPC();

            this._type = NKEBrowserType.MSWebView.ToString();
            if (options.itemOrDefault<bool>("NKE.InstallElectro", true))
                await Renderer.addElectro(_browserWindow.context, options);
            NKLogging.log(string.Format("+E{0} Renderer Ready", _id));

            _browserWindow.events.emit("NKE.DidFinishLoad", _id);

        }
        private async Task startNodeKitMain(Dictionary<string, object> options)
        {
            NKEventEmitter.isMainProcess = true;

            options.set("NKS.MainThreadScheduler", TaskScheduler.FromCurrentSynchronizationContext());
            options.set("NKS.MainThreadId", Environment.CurrentManagedThreadId);
            var entryClass = options.itemOrDefault("NKS.Entry", typeof(NKC_NodeKit));
      
            context = await NKScriptContextFactory.createContext(options);
         
            // SCRIPT ENGINE LOADED, ADD {NK} NODEKIT
            await NKElectro.Main.addElectro(context, options);
            await NKCore.Main.addCorePlatform(context, options);
            await NKCore.Main.bootCore(context, options);

            // {NK} NODEKIT ADDED, START APPLICATION 
    //        var appjs = await NKStorage.getResourceAsync(entryClass, "index.js", "app");
   //         var script = "function loadapp(){\n" + appjs + "\n}\n" + "loadapp();" + "\n";
    //        await context.NKevaluateJavaScript(script, "io.nodekit.electro.main");

            NKEventEmitter.global.emit<string>("NK.AppReady");
        }
        public void loadURL(string url, Dictionary<string, object> options)
        {
            var httpReferrer = options.itemOrDefault<string>("httpReferrer");
            var userAgent = options.itemOrDefault<string>("userAgent");
            var extraHeaders = options.itemOrDefault<Dictionary<string, object>>("extraHeaders");
            var uri = new Uri(url);

            var request = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Get, uri);
            if ((userAgent) != null)
                  request.Headers["User-Agent"] = userAgent;

            if ((httpReferrer) != null)
                request.Headers["Referrer"] = httpReferrer;

            if ((extraHeaders) != null)
            {
                foreach (var item in extraHeaders)
                {
                    request.Headers[item.Key] = item.Value as string;
                }
            }

            webView.NavigateWithHttpRequestMessage(request);
        }
          public void loadURL(string url, Dictionary<string, object> options)
        {
            var httpReferrer = options.itemOrDefault<string>("httpReferrer");
            var userAgent = options.itemOrDefault<string>("userAgent");
            var extraHeaders = "";

            foreach (var item in options.itemOrDefault<Dictionary<string, object>>("extraHeaders", new Dictionary<string, object>()))
            {
                extraHeaders += item.Key + ": " + item.Value + "\n";
            }
            var uri = new Uri(url);

            webView.Navigate(uri, "_self", null, extraHeaders);
        }