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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:57:10+00:00 2026-05-25T06:57:10+00:00

I have an audio recording app in Windows Phone 7. The app allows a

  • 0

I have an audio recording app in Windows Phone 7.
The app allows a user to play the recorded sounds.

I try to stick to MVVM guidelines where it is possible.

I have a play/stop button in a list of all recordings. Each recording has its own ViewModel, which, besides all, also controls the look of the corresponding play/stop button.

The button has a custom visual state defined in its’ style.

The Visual State is bound to the ViewModel’s property using the approach, shown here:
http://tdanemar.wordpress.com/2009/11/15/using-the-visualstatemanager-with-the-model-view-viewmodel-pattern-in-wpf-or-silverlight/

Having implemented this approach, whenever I want to change the look of the play/stop button, I need to set the public string property (named “PlayStopVisualState”) in my ViewModel to either “PlayingState” or “Normal”, and that will assign an appropriate visual state to my button.

The problem is that when user presses the play button, a SoundEffectInstance is created in a background thread, which plays the sound. The thread then waits for the playing to end. When the recording playing is over (I have to track it in the same background thread, or create another for just tracking SoundEffectInstance.State) I set the PlayStopVisualState property back to “Normal”, but I get a cross-thread reference exception. Isn’t MVVM specifically designed to allow developers to manipulate logical variables in a view model, and not having to worry about how the changes to them are reflected in a View?

I know that I need to do the adjustment of the PlayStopVisualState property in a Dispatcher thread in order for the problem to disappear, but this is just no right. It, from my point of view, defeats the whole purpose of MVVM, leaving only the organizational advantage.

Or am I doing something wrong? Thanks.

UPDATE:
I have worked around the problem by using

Deployment.Current.Dispatcher

but it seems to me as a very “ugly” solution, given that I almost all over have MVVM pattern followed.

  • 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-25T06:57:11+00:00Added an answer on May 25, 2026 at 6:57 am

    Using the Dispatcher to reflect a UI-bound value is the correct way to do it, yes.

    What you’re forgetting is that your ViewModel is created on the UI thread. So any change to the ViewModel from a background thread, would a cross-thread operation.

    You should consider if a background thread is really needed. , or if you could just schedule your action on the UI thread directly.

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

Sidebar

Related Questions

I have a web app(jsp/servlets) which allows users to download audio files and play
I have an app which allows user to import media (videos, photos, audio) which
I currently have 3 ways to play audio within my app: Using AudioServicesPlaySystemSound for
I have an app with callbacks for recording and playing audio. From the recording
I have developed android phonegap app.I am recording the audio through phonegap api and
I have an upload phone app that uploads either images or audio recordings. The
I have a user recording and another mp3 file in my app, and I
I have an app in which records audio files. User can specify length of
I have a view responsible for recording audio. How can i record several audios
I have an Audio app using AVAudioPlayer on iOS. Whenever music is playing my

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.