Пример #1
0
        private void LoadHandler_OnLoadError(object sender, CfxOnLoadErrorEventArgs e)
        {
            if (e.ErrorCode == CfxErrorCode.Aborted)
            {
                //Aborted is raised during hot-reload
                //We will not poluate log nor stop the application
                return;
            }

            _Logger.Error($@"Unable to load ""{e.FailedUrl}"": ""{e.ErrorCode}"". Please check that the resource exists, has the correct ""Content"" and ""Build Type"" value or is correctly served.");
            if (!e.Frame.IsMain)
            {
                return;
            }

            _Logger.Error("Closing application");
            _Dispatcher.RunAsync(async() =>
            {
                //Delay here to be sure to finish all chromium related task
                //before closing application. This will avoid additional exception
                //due to inconsistent state.
                await Task.Delay(10);
                Application.Current.Shutdown(-1);
            });
        }
        internal static void on_load_error(IntPtr gcHandlePtr, IntPtr browser, IntPtr frame, int errorCode, IntPtr errorText_str, int errorText_length, IntPtr failedUrl_str, int failedUrl_length)
        {
            var self = (CfxLoadHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;

            if (self == null || self.CallbacksDisabled)
            {
                return;
            }
            var e            = new CfxOnLoadErrorEventArgs(browser, frame, errorCode, errorText_str, errorText_length, failedUrl_str, failedUrl_length);
            var eventHandler = self.m_OnLoadError;

            if (eventHandler != null)
            {
                eventHandler(self, e);
            }
            e.m_isInvalid = true;
            if (e.m_browser_wrapped == null)
            {
                CfxApi.cfx_release(e.m_browser);
            }
            if (e.m_frame_wrapped == null)
            {
                CfxApi.cfx_release(e.m_frame);
            }
        }
Пример #3
0
        internal static void EventCall(object sender, CfxOnLoadErrorEventArgs e)
        {
            var call = new CfxOnLoadErrorBrowserProcessCall();

            call.sender      = RemoteProxy.Wrap((CfxBase)sender);
            call.eventArgsId = AddEventArgs(e);
            call.RequestExecution(RemoteClient.connection);
            RemoveEventArgs(call.eventArgsId);
        }
Пример #4
0
 void LoadHandler_OnLoadError(object sender, CfxOnLoadErrorEventArgs e)
 {
     if (e.ErrorCode == CfxErrorCode.Aborted)
     {
         // this seems to happen when calling LoadUrl and the browser is not yet ready
         var url   = e.FailedUrl;
         var frame = e.Frame;
         ThreadPool.QueueUserWorkItem((state) => {
             Thread.Sleep(200);
             frame.LoadUrl(url);
         });
     }
 }
Пример #5
0
        internal static void on_load_error(IntPtr gcHandlePtr, IntPtr browser, out int browser_release, IntPtr frame, out int frame_release, int errorCode, IntPtr errorText_str, int errorText_length, IntPtr failedUrl_str, int failedUrl_length)
        {
            var self = (CfxLoadHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;

            if (self == null || self.CallbacksDisabled)
            {
                browser_release = 1;
                frame_release   = 1;
                return;
            }
            var e = new CfxOnLoadErrorEventArgs(browser, frame, errorCode, errorText_str, errorText_length, failedUrl_str, failedUrl_length);

            self.m_OnLoadError?.Invoke(self, e);
            e.m_isInvalid   = true;
            browser_release = e.m_browser_wrapped == null? 1 : 0;
            frame_release   = e.m_frame_wrapped == null? 1 : 0;
        }
Пример #6
0
 internal static void EventCall(object sender, CfxOnLoadErrorEventArgs e)
 {
     var call = new CfxOnLoadErrorBrowserProcessCall();
     call.sender = RemoteProxy.Wrap((CfxBase)sender);
     call.eventArgsId = AddEventArgs(e);
     call.RequestExecution(RemoteClient.connection);
     RemoveEventArgs(call.eventArgsId);
 }