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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:08:04+00:00 2026-05-11T05:08:04+00:00

I have the following problem: Multithreaded WPF application, Model View Presenter Implementation. Presenters and

  • 0

I have the following problem: Multithreaded WPF application, Model View Presenter Implementation. Presenters and Views that belong together are created by a factory on a separate thread and should get a separate Dispatcher.

Public Function CreatePresenter(Of T As {New, Class})(ByVal p_eCreationOptions As eViewCreationOptions) As T Implements IPresenterFactory.CreatePresenter      Select Case p_eCreationOptions         Case eViewCreationOptions.CreateInCallingThread             CreatePresenter(Of T)()         Case eViewCreationOptions.CreateInNewThread             Dim oThread As New Thread(New ThreadStart(AddressOf CreatePresenter(Of T)))             oThread.SetApartmentState(System.Threading.ApartmentState.STA)             oThread.Start()             oThread.Join()         Case Else             Throw New InvalidOperationException('Need to specify creation options.')     End Select      Return CType(m_oCreatedPresenter, T)  End Function  Private Sub CreatePresenter(Of T As {New, Class})()     m_oCreatedPresenter = Activator.CreateInstance(Of T)() End Sub 

The problem is, now the presenter is created on the other thread and the thread goes dormant after creation, but the dispatcher on there isn’t running yet. Now, if I’m coming from the main UI thread where the application lives and make a call to my presenter, Im creating the view, show it and now only i can call Dispatcher.Run().

Public Overloads Sub Show()     Console.WriteLine ('Show Caller ThreadID = ' & Thread.CurrentThread.ManagedThreadId)     MyBase.Show()     System.Windows.Threading.Dispatcher.Run() End Sub 

But what I want to do is, when a method on the presenter is called from another thread than where the presenter lives, invoke the method again on the thread of the presenter where he has his own Dispatcher, so that I don’t need to deal with the Dispatcher on calls between my Presenter and the view. Is that possible at all, is my design flawed or is there any better way to achieve what i want?

  • 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. 2026-05-11T05:08:04+00:00Added an answer on May 11, 2026 at 5:08 am

    The problem is that the Dispatcher doesn’t start when there’s no DispatcherObject instantiated on the new thread, but if you instantiate a dummy object and then invoke the method of your presenter, the dispatcher will run properly. For example

     private void ThreadStartingPoint()    {        var dummyDispatcherObject = new Style();        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(CreatePresenterInternal));        Dispatcher.Run();   }   

    A full solution to this can be found on my blog.

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

Sidebar

Ask A Question

Stats

  • Questions 211k
  • Answers 211k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Is the custom action running with elevation? This is a… May 12, 2026 at 10:14 pm
  • Editorial Team
    Editorial Team added an answer Hmm, I will just throw this :) We have smth… May 12, 2026 at 10:14 pm
  • Editorial Team
    Editorial Team added an answer You should look up link_to_remote and using AJAX with rails.… May 12, 2026 at 10:14 pm

Related Questions

Let's say I have a multithreaded C++ program that handles requests in the form
I have a multithreaded application that runs using a custom thread pool class. The
I have a distributed Java application running on 5 application servers. The servers all
I have the following program to open lot's of sockets, and hold them open

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.