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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:51:15+00:00 2026-05-23T19:51:15+00:00

I am developing using Entity Framework and WPF, and I am encountering some errors

  • 0

I am developing using Entity Framework and WPF, and I am encountering some errors and I don’t know why. When saving a record (using a BackgroundWorker), I set the entities change tracker to nothing (null), attach the record to a new disposable context, save it, detach, and dispose of the context.

Saving a record fires and event in theMainViewModel of the program that the other ViewModels (including the one that is saving) need to refresh their entities to reflect changes.

Private Sub _saveRecordWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles _saveRecordWorker.DoWork
    Using MyContext As New RVShippingEntities
        Dim MyShipment = CType(ShipmentRecord, IEntityWithChangeTracker)
        MyShipment.SetChangeTracker(Nothing)
        MyContext.Attach(MyShipment)
        MyContext.Detach(ShipmentRecord)
    End Using
End Sub

The Refresh background worker is similar, but it has a Do While block to keep it from interfering with the save worker (which doesn’t appear to be working; hence the post). When I save (and it subsequently refreshes) I get the following error:
The calling thread cannot access this object because a different thread owns it.

I thought that with theDoWhile block, it would wait (and when I step through it does) until the save thread finished, and all would be good. But it would seem that something (either the main thread or the save thread) is still doing something that is interfering.

Is there a better way of doing this? Am I doing it in a goofy kludgey fashion? Any help would be appreciated.

(Apparently Firefox recognized kludgey as a word. Interesting)

  • 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-23T19:51:15+00:00Added an answer on May 23, 2026 at 7:51 pm

    So, 3+ months and nary an exception so far in relation to Entity Framework. I am going to call this the answer.

    Parent Views (in my case Company, Customer, Shipment) have a context which is passed to child Views as necessary (Addresses, Phone Nums, Email Addresses, for Company and Customer; Packages, Contents, for Shipments). Anytime a context can’t save changes or what have you (db disconnection is most common cause), the context is disposed, a new one instanced, the entities are re-attached, set to modified (based on custom change tracking which I do for UI), and changes are saved.

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

Sidebar

Related Questions

I am developing application using Entity Framework. When i'm in debugging mode my test
I am developing a medium sized ASP.NET project using ASP.NET MVC and Entity Framework.
I am developing an ASP MVC application using Entity Framework. I was thinking of
I have begun developing an application using the Entity Framework. I have added a
I'm currently developing an app using ASP.NET MVC3 and Entity Framework 4.1 Code First
I am developing an application that uses Entity Framework and WPF with MVVM design
I'm developing a web application using ASP.NET MVC 3 and Entity Framework Code First
I was developing an application using Entity Framework and storing data in a .mdf
I'm currently developing an app using Entity Framework 4.1 and MySQL. I want to
I'm developing a web app using the entity framework. I load a list of

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.