Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Getting a weird ContextSwitchDeadlock after I paste in large amounts of HTML to the RichTExtEditor
posted

I have a XamRichTextEditor that I am using and I have recently gotten some weird errors when trying to manually refresh the value of my HtmlDocumentAdapter manually. I want my HtmlDocumentAdapter.Value to be equivalent to a custom Dependency Property on my custom control (that utilizes the XamRichTextEditor and HtmlDocumentAdapter, amoung other things). 

The code fires in the XamRichTextEditor.Document.ContentChanged event. Here is some example code:

private void Document_ContentChanged(Object sender, DocumentContentChangedEventArgs e)
{
if (!this.htmlLostFocusTrigger && this.htmlAdapter != null)
{
try
{
this.htmlAdapter.RefreshValue();
this.Html = this.htmlAdapter.Value;
this.htmlExp.UpdateSource();
}
catch { }
}
}

When this.Html = this.htmlAdapter.Value; fires I get a weird exception and my UI completely blocks and freezes. After waiting a while I get a ContextSwitchDeadlock exception.

Note, this happens after I paste html then try to add some new content to the editor. Something is breaking. If I remove that line all seems to be fixed, but then my bindings work improperly.

Attached is the html I am pasting, my CS file, and my XAML theme for my custom control. 

Examples.zip
Parents
No Data
Reply
  • 22015
    posted

    Hello Carson,

     

    Thank you for posting!

     

    I have been looking into your issue and have created a small sample application in order to test the scenario you have reported. In the sample application I have extracted the code related to the XamRichTextEditor from the two files you have provided and handled the ContentChanged event of the Document of the XamRichTextEditor.

    Then in the handler of the event I have placed the code snippet, that you have mentioned and everything works as expected when the HTML is pasted and I try to add new content via typing.

     

    I am attaching the sample application I have been testing with. As you are creating a custom control would you please modify the sample application with the functionality you are using so it reproduces the issue? This way I would be able to further investigate this matter for you.


    Looking forward to hearing from you.

    RichTextEditor_HTMLDockAdapter.zip
Children