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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:06:11+00:00 2026-05-27T01:06:11+00:00

I have a search through database. Search works in separate thread. When entity is

  • 0

I have a search through database. Search works in separate thread.
When entity is found I have to show it and some of related data into WPF UI.

I use EntityFramework. Main idea of search process is:

foreach (var item in _currentEntitySet)
{     
    Items.Add(item);
    OnItemFound(item);
}

Where _currentEntitySet is an ObjectQuery

But I have met some problems. When OnItemFound is fired, I try to use BeginInvoke() to display found item and some related object in UI.

    private void OnCatalogueItemFound(CatalogueItem item)
    {
        Application.Current.Dispatcher.BeginInvoke(new Action<object>((param) =>
        {                
            var model = new CatalogueResultItemViewModel(param as CatalogueItem);
            TitlesResultViewModel.Add(model);
        }), System.Windows.Threading.DispatcherPriority.Background, item);
    }

The problem is that navigation properties of item are NULL

When I use Invoke() instead of BeginInvoke() then things works fine.
I have to use exactly BeginInvoke() because of some other reasons.

Does anyone knows how can I use BeginInvoke() in my situation? Thanks 🙂

  • 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-27T01:06:12+00:00Added an answer on May 27, 2026 at 1:06 am

    I think that this may be because you are generating your object with a lambda function.

    BeginInvoke is called asynchroimously and possibly by the time it is actioned the object locatedis no longer in scope.

    By using Invoke you force the call to be performed synchronously, when the object is still in scope.

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

Sidebar

Related Questions

I have a project that interacts with a database through ADO.net Data Services. The
I have search through google and found that a lot of people is struggling
I'm using Hibernate Search (which uses Lucene) for searching some Data I have indexed
I have search through the web to figure this out but no luck. I
I have to search through a list and replace all occurrences of one element
Recently, I have been going through search trees and I encountered red-black trees, the
I need to do a significant search through my SourceSafe 8 database to support
I have designed a basic search in ASP/C# for searching through records in a
I'm doing a search through a database to find articles written within a certain
I have search in MSDN and I can't figure where are the POST parameters

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.