RadDocument processing in Background processes

4 posts, 0 answers
  1. Alex
    Alex avatar
    2 posts
    Member since:
    Aug 2012

    Posted 12 Feb 2013 Link to this post

    Hi Telerik,

    I have a few questions regarding the usage of the RadDocument.  According to my scenario I prepare different Documents in Designer (using RadRichTextBox) with Placeholders,  which are implemented with the InlineUIContainers and child TextBlock element,  and then this serialize document to HTML and retain in the Storage.
    In the various Application background processes we use the prepared Doument "template" for generating HTML documents,  by replacing the Placeholders with the real-time data.
    To do it, we 
    try to deserialize the RadDocument from the HTML and then use RadDocument DOM model for easier and safer Placeholder replacement operation.  The only way we found to do it on Application Server is to use methods  HtmlFormatProvider.Import, HtmlFormatProvider.Export. BUT they are not designed to be used in a such way as they expect to be run only in STA thread, so we got an exception:

    InvalidOperationException with message "The calling thread must be STA, because many UI components require this."

    Creating a dedicated STA thread for processing each documents works only under non-stressful conditions, and definitely failed on contrary with the confusing exception:

    System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully

    Could you please suggest any way to overcome our problem, or suggest another approach for working with RadDocuments in background processes?



  2. Boby
    Boby avatar
    588 posts

    Posted 13 Feb 2013 Link to this post

    Hi Alex,
    Unfortunately this is known issue with RadDocument, caused by the fact that in the current implementation document model is coupled with some UI elements. We have plans to improve this and allow usage of the format providers in MTA threads, as well as in multi-threading scenarios, but for now it's not clear when this will be implemented. Until then, you only options is to use RadDocument in STA thread.

    We have previous reports of "The operation completed successfully" exception and it seems that it is caused by an issue in .NET framework. You can try if the workaround suggested in the thread works for you:

    You can work around this bug by adding the following code to your thread proc:
    Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
    This asks the dispatcher associated with the thread to shut down right away.

    Don't hesitate to contact us if you have other questions.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. Jeff
    Jeff avatar
    3 posts
    Member since:
    Nov 2010

    Posted 12 Dec 2013 Link to this post

    Hello, has this change been applied in any of the recent versions, or is there a place that I can track this feature's progress? 
  5. Petya
    Petya avatar
    973 posts

    Posted 14 Dec 2013 Link to this post

    Hello Jeff,

    The change was introduced in our latest official version. There is also an example of this in our SDK demos (you can find the demo here as well).

    Let me know if you have any other questions.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top