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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:54:52+00:00 2026-06-08T06:54:52+00:00

I am invoking a service module call from my viewmodel in the background thread

  • 0

I am invoking a service module call from my viewmodel in the background thread by using a background worker, all fine and dandy.

The service module method has an action parameter which is invoked when the service returns. Now I need to get back to the UI thread at this point to invoke the action (I have also tried getting back to the UI thread in my viewmodel method which is invoked from the service module.)

So to the crux of the matter I have tried

Application.Current.RootVisual.Dispatcher.BeginInvoke(() => code stuff here);

Which produces invalid cross thread access (fine I cant get to rootvisual here I understand)

I then tried to get the Dispatcher a different way as below

Deployment.Current.Dispatcher.BeginInvoke() => code here);

I have also tried a static class which has a Dispatcher property which I set in my application startup method and then try invoke using that.

Whilst using the Deployment dispatcher and my static class’s dispatcher do not produce invalid cross thread access, the crux that has me so confused is that if i breakpoint inside the code that is being invoked by these dispatchers then I get this System.Threading.Thread.CurrentThread.ThreadState is Background

I can however update my properties in my view model and the view does indeed update without an issue, but I want to know if there is still something going wrong here and this will be a problem in the future.

  • 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-08T06:54:54+00:00Added an answer on June 8, 2026 at 6:54 am

    To get to the UI dispactcher you can use this code –

    Application.Current.Dispatcher.BeginInvoke() => code here);
    

    For your comment –

    I should add the most confusing part is from what I’ve read using a dispatcher is meant to guarantee you get back onto the UI thread!

    You have misinterpreted that invoking a delegate on UI dispatcher will take you to UI thread, the above piece of code invocation will only queue the delegate on UI dispatcher and will execute on the UI thread. However, execution point will be there on the background thread from where you are calling this action.

    These links might be useful to you – Understanding Dispatcher and Overview of dispatcher

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

Sidebar

Related Questions

Background: I'm invoking a web service method which returns a JSON string. This string
I have a service which has a method that downloads an image from an
I am invoking a web service function which is reading a users credentials from
I am using this example from microsoft to call web services dynamically using reflection:
So I have a service clint class that has a method called fetch. I
I have looked at several tutorials using android and ksoap2. My service works fine
I'm using the UPS service to monitor the state of my UPS from an
I am invoking .NET WCF data service. Everything seems to be working fine, but
Im trying to consume a web service using the below WSDL from a .NET
I'm Invoking an Activity from my Service . I do this whenever an event

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.