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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:25:50+00:00 2026-05-15T08:25:50+00:00

I have a Silverlight application that consists of a MainWindow and several classes which

  • 0

I have a Silverlight application that consists of a MainWindow and several classes which update and draw images on the MainWindow. I’m now expanding this to keep track of everything in a database.

Without going into specifics, lets say I have a structure like this:

MainWindow
  Drawing-Surface
    Class1 -- Supports Drawing
      DataContext + DataServiceCollection<T> w/events
    Class2 -- Manages "transactions" (add/delete objects from drawing)
    Class3

Each “Class” is passed a reference to the Drawing Surface so they can interact with it independently.

I’m starting to use WCF Data Services in Class1 and its working well; however, the other classes are also going to need access to the WCF Data Services. (Should I define my “DataContext” in MainWindow and pass a reference to each child class?)

Class1 will need READ access to the “transactions” data, and Class2 will need READ access to some of the drawing data. So my question is, where does it make the most sense to define my DataContext?

Does it make sense to:

  1. Define a “global” WCF Data Service “Context” object and pass references to that in all of my subsequent classes?
  2. Define an instance of the “Context” for each Class1, Class2, etc
  3. Have each method that requires access to data define its own instance of the “Context” and use closures handle the async load/complete events?

Would a structure like this make more sense? Is there any danger in keeping an active “DataContext” open for an extended period of time? Typical usecase of this application could range from 1 minute to 40+ minutes.

MainWindow
  Drawing-Surface
  DataContext
    Class1 -- Supports Drawing
      DataServiceCollection<DrawingType> w/events
    Class2 -- Manages "transactions" (add/delete objects from drawing)
      DataServiceCollection<TransactionType> w/events
    Class3
      DataServiceCollection<T> w/events
  • 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-15T08:25:50+00:00Added an answer on May 15, 2026 at 8:25 am

    In general you should not keep the context around for too long. The context holds references to all entities you get from it (unless you turn off change tracking) and thus if you hold on to it you’re also holding all the entities in memory.
    If your access is read-only then I would really only consider the lifetime of the entities (and the memory consumption related to it).
    If your access is read-write then if you have two contexts and make changes to some entity from one, the other will not see it. So you probably want a single context in that case. But the lifetime issues still apply.

    So if you know you’re not going to use lot of different entities I would use just one context for simplicity (and it allows you to share instances). If you know you’re going to use lot of entities, then I would think about droping the context once in a while (in some logical place in your application).

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

Sidebar

Related Questions

I have a Silverlight application which has on it a Canvas. On that Canvas,
I have a silverlight application that uses wcf service. This application is shown from
I have a Silverlight application that is interacting with a WCF service. This service
I have a Silverlight application that is building a URL. This URL is a
I have a Silverlight 4 application that uses a DataGrid. This DataGrid is bound
I have a Silverlight application that consists of many pages that uses Navigation Framework.
I have a simple Silverlight application that consists of four pages (XAMLs). Navigation is
I have a Silverlight application that I am trying to style. This style simply
I have a Silverlight application that is built from a set of Silverlight class
I have a Silverlight application that communications with an ASP.NET backend through WCF. I

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.