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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:46:26+00:00 2026-05-11T20:46:26+00:00

I am writing an app that listens on a network connection, and when some

  • 0

I am writing an app that listens on a network connection, and when some data arrive, it replies back, and depending on incoming data, it may need to ask user (show dialog) before replying back.

I don’t know how to do this cleanly in M-V-VM architecture: the events and binding to observable collections are nice if I need to just update GUI based on incoming data, but what if I actually need an anwer from user before replying back?

And to make things worse, I want to do it synchronously, because I want my reply algorithm to be at one place, not partitioned into multiple callbacks with unclear ‘who-calls-who’ responsibilities.

Simply, something like

HandleMessage(Message msg){
    string reply;
    if (msg.type == 1) {
        reply = ...
    } else {
        string question = msg...
        reply = ShowModalDialog(question); // MVVM violation!
    }
    sender.Send(reply);
}

but I don’t want to call view or viewmodel from model, as model needs to be reusable and testable – I don’t want popping dialogs in every test run, and it would be violation of MVVM! No events (they are just one-way as far as i know, and have no backwards channel to get reply to event origin) or databinding, as it would be asynchronous.

Is this doable? This is a question I asked several test driven development propagators, and so far, I didn’t get practically usable answer. Yet, a need for some additional input in the middle of processing is fairly common.

Thanks!

EDIT: this is application logic, so it clearly belongs to model, and even if in this case it didn’t, I’d like to know the solution for cases when I really need user’s input in the middle of business logic routine in model.

  • 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-11T20:46:26+00:00Added an answer on May 11, 2026 at 8:46 pm

    This is one of those problems that MVVM doesn’t solve on it’s own. One solution would be to use a service to query the user and then have the ViewModel use that service.

    In my project we’re using PRISM which besides providing a services framework also provides other tools for making GUI development easier.

    Here’s a writeup of how services work in PRISM.

    So specifically in your case I would create some sort of IOC, register a query service with it, then in the ViewModel pass in the IOC and then use the IOC to get the query service, and use that to query the user. More work? Sure. But it means you can replace the query service with another implementation for testing by simply replacing it in the IOC.

    MVVM + Services = Ultimate Power!

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

Sidebar

Related Questions

I'm writing an app that will need to make use of Timer s, but
I'm writing a app that exposes a REST API. Some of the query parameters
I'm writing an app that contains the following tables: (1) employee_type, (2) employee and
I'm writing an app that lets a diabetic user enter his/her blood glucose readings,
I'm writing an app that supposed to copy a bunch of files from one
I am writing an app that allows people to schedule things for certain times
Here is the scenario: I'm writing an app that will watch for any changes
I'm writing a simple app that's going to have a tiny form sitting in
I'm writing a web app that points to external links. I'm looking to create
I'm writing an winforms app that needs to set internet explorer's proxy settings and

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.