Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6733385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:45:44+00:00 2026-05-26T10:45:44+00:00

I have a UserControl that is added to my Main window. The Main code

  • 0

I have a UserControl that is added to my Main window. The Main code continuously receives TCP messages and interacts with the UserControl accordingly. One of the UserControl’s methods that is called by Main is AddMessage:

internal void AddMessage(Paragraph p)
{
    if (txtViewer.Dispatcher.CheckAccess())
    {
        txtViewer.Document.Blocks.Add(p);
    }
    else
    {
        Dispatcher.Invoke(new Action(() =>
            {
                txtViewer.Document.Blocks.Add(p);
            }
        ));
    }
}

The line within Dispatcher.Invoke always throws an InvalidOperationException. I’ve looked around at similar issues, and most of them were cases where the Dispatcher wasn’t being used, so I don’t know why my code isn’t working. I suppose I’m using it incorrectly, or it may have something to do with the Paragraph object being passed between threads.

Thanks,
Jared

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:45:45+00:00Added an answer on May 26, 2026 at 10:45 am

    I had a similar problem in could not bind a DocumentViewer asynch as FlowDocument derived from Dispatcher. The UI cannot bind to an object that derives from Dispatcher on another thead. I had to serialize the FlowDocument to string (does not derive from dispatcher) using XamlWriter.Save then de-serialize in a Converter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Window1.xaml main Window; and after some event, I display a UserControl
I have a UserControl that I've added a Dependency Property to: public partial class
I have a usercontrol that has several public properties. These properties automatically show up
I have a UserControl that consists of three TextBoxes. On a form I can
I have a usercontrol that is meant to take up the entire form. I
I have created a UserControl that has a ListView in it. The ListView is
I have a Page that has a single instance of a UserControl that itself
If I have a usercontrol (in Silverlight) that I've written, that uses XAML to
I have a UserControl in my Asp.net project that has a public property. I
i have a user control that descends from UserControl. When dropped onto the form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.