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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:20:15+00:00 2026-06-01T17:20:15+00:00

So I have a WPF application using the MVVM pattern (Caliburn.Micro). I got the

  • 0

So I have a WPF application using the MVVM pattern (Caliburn.Micro). I got the views and view-models wired up and basicly what is missing is the data. The data is to be retrieved “on-demand” either from a WCF service, local storage or from memory/cache – reason being to allow for offline-mode and to avoid uneccessary server communication. Another requirement is that the data is retrieved asynchronously so the UI thread is not blocked.

So I was thinking to create some kind of “AssetManager” that the viewmodels use to request data:

_someAssetManager.GetSomeSpecificAsset(assetId, OnGetSomeSpecificAssetCompleted)

Note that it is an asynchronous call. I run into a few different problems though. If the same asset is requested at (roughly) the same time by different view-models, how do we ensure that we don’t do unecessary work and that they both get the same objects that we can bind against?

Not sure I’m having the right approach. I’ve been glancing a bit at Reactive Framework – but I have no idea how to use it in this scenario. Any suggestions on framework/techniques/patterns that I can use? This seems to be a rather common scenario.

  • 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-06-01T17:20:16+00:00Added an answer on June 1, 2026 at 5:20 pm
    Dictionary<int, IObservable<IAsset>> inflightRequests;
    
    public IObservable<IAsset> GetSomeAsset(int id)
    {
        // People who ask for an inflight request just get the
        // existing one
        lock(inflightRequests) {
            if inflightRequests.ContainsKey(id) {
                return inflightRequests[id];
            }
        }
    
        // Create a new IObservable and put in the dictionary
        lock(inflightRequests) { inflightRequests[id] = ret; }
    
        // Actually do the request and "play it" onto the Subject. 
        var ret = new AsyncSubject<IAsset>();
        GetSomeAssetForReals(id, result => {
            ret.OnNext(id);
            ret.OnCompleted();
    
            // We're not inflight anymore, remove the item
            lock(inflightRequests) { inflightRequests.Remove(id); }
        })
    
        return ret;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Caliburn and the MVVM pattern in a WPF application, and am trying
I am coding a WPF application using MVVM pattern. I don't need to have
I have a WPF Microsoft Surface Application and I'm using MVVM-Pattern. I have some
I am developing an application in WPF using the MVVM pattern. If I have
I have an application I am creating in WPF, using MVVM pattern. In this
I'm trying to implement a WPF application using MVVM (Model-View-ViewModel) pattern and I'd like
I have a WPF Application using MVVM pattern. I have a Window in my
I'm writing an application using WPF MVVM. I have a view model with property
Using the MVVM pattern creating WPF applications you have the ViewModel providing data to
I'm writing a WPF application using the MVVM pattern, based on the following article:

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.