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

  • SEARCH
  • Home
  • 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 7278857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:55:58+00:00 2026-05-28T22:55:58+00:00

I came across a problem while trying to manipulate the FlowDocumentScrollViewer control in WPF.

  • 0

I came across a problem while trying to manipulate the FlowDocumentScrollViewer control in WPF. I did searched through the internet about this kind of error, but found my problem is quite unique.

this is the code:

    delegate void delg_FlowDoc(FlowDocument fdoc);

    //Function provided for both internal calling and outside calling 
    public void setfDocDisplay(FlowDocument fdoc)
    {

        FlowDocumentScrollViewer display = this.fDocDisplay;  //control to be operated

        if (display.Dispatcher.CheckAccess())
        {
            //called from own thread, just operate directly!

            string debug_check_ThreadName = Thread.CurrentThread.Name;
            if (debug_check_ThreadName == "Thread_MainUI")
            {

                //Debug only, now current thread MUST be the thread
                //created the UI!!!!
                display.Document = fdoc;  //<-- Error this line
            }
        }
        else
        {
            //called from other threads, use Invoke()!
            delg_FlowDoc pFun = new delg_FlowDoc(setfDocDisplay);
            this.Dispatcher.Invoke(pFun, new object[] { fdoc });

            //display.Dispatcher.Invoke(pFun, new object[] { fdoc });
            //this.Dispatcher.BeginInvoke(pFun, new object[] { fdoc });
        }
    }

And an error occurred in line display.Document = fdoc;, saying still cannot access the control from a different thread.

And this is the detailed snapshot of error:
Error!

I am confused since:

  1. I have already performed display.Dispatcher.CheckAccess() to ensure current thread has the permission to operate on the control display.

  2. I again add a debug_check_ThreadName to double ensure it’s in the right thread for that moment.

  3. I tried exactly the same code in another but smaller WPF project that is free of errors

But still got the same problem telling me I try to operate from a different thread.

I am not familiar with other properties of Dispatcher or Invoke etc. properties so I have no idea now to solve this problem.

If anyone can give me any hint of this error?

Thank you!

[SOLVED]

Thank you 500 – Internal Server Error!

Since I am still shocked by the fact, I decide to put my understanding in the question to facilitate some one else have the same problem and saw this question.

I have now fixed the problem. It is because the FlowDocument fdoc is actually a type of UI control and created in another thread. So when the main windows thread want to operate that fdoc – although it has permission to FlowDocumentScrollViewer display – it doesn’t have permission to the other control fdoc in this assignment sentence.

It’s rather weird!! I thought fdoc is just a normal variable like a string or int vars… ><

  • 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-28T22:55:58+00:00Added an answer on May 28, 2026 at 10:55 pm

    It is not the control you (try to) assign to that’s the problem – it’s the source document that’s not created on the UI thread.

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

Sidebar

Related Questions

I came across this problem while preparing for an interview and curious to know
I am watching a video about [LINQ][1] and came across a problem. In this
I came across this website while looking for help on the internet regarding adj.
While reading Learning Perl , I came across a problem about regular expressions. In
While trying to model my domain, I came across the following problem. Let's image
While investigating a reported problem with my site loading slowly, I came across an
I am new to creating Java web applications and came across this problem when
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
I was practicing SRM Problems in Topcoder.I came across this problem Problem Statement: Today
The Problem It's something I came across a while back and was able to

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.