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 473837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:13:37+00:00 2026-05-13T00:13:37+00:00

I’m trying to create a custom, in-house application that is going to access other

  • 0

I’m trying to create a custom, in-house application that is going to access other internal systems which broadcast their names and IP addresses via UDP. I’m trying to create a multi-threaded dialog that polls for UDP messages every 500 ms for 15 seconds, parses the UDP messages and then adds the names of the detected systems to a ListBox in the dialog, updating it in real time. I’ve already got the UDP scanning code tested and done, the only problem is updating the ListBox across threads. Any time I try to access the ListBox’s Items or ItemSource properties, I get a System.InvalidOperationException : “The calling thread cannot access this object because a different thread owns it.”

The relevant stack trace portion:

   at System.Windows.Threading.Dispatcher.VerifyAccess()
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.ItemsControl.set_ItemsSource(IEnumerable value)

This occurs regardless of whether I’m using an ObservableCollection (I know, has nothing to do with the collection type), a HashSet or any other object. Can anybody help me with accessing the GUI across different threads ?

  • 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-13T00:13:37+00:00Added an answer on May 13, 2026 at 12:13 am

    You can’t access the gui safely from other threads. All calls have to be dispatched via a call to Invoke to be executed on the main thread. This is a legacy hang-up that Windows has been saddled with for years.

    Here’s a snippet of code that should get you started…
    (found here: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/360540eb-d756-4434-86f9-a3449f05eb55/ )

    if(textbox.Dispatcher.CheckAccess())
    {
       // The calling thread owns the dispatcher, and hence the UI element
       textbox.AppendText(...);
    }
    else
    {
       // Invokation required
       textbox.Dispatcher.Invoke(DispatcherPriority.Normal, [delegate goes here]);
    }
    

    There is additional clarification here: http://channel9.msdn.com/forums/TechOff/251835-WPF-Invoke-and-Anonymous-delegates/

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from

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.