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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:18:52+00:00 2026-06-07T21:18:52+00:00

I have large WPF-MVVM application in which I have 1 subscribe and 2 publish

  • 0

I have large WPF-MVVM application in which I have 1 subscribe and 2 publish patterns.
I have subscribed an event as follows:

EventAggregator.GetEvent<StatusMessageEvent>().Subscribe(OnCommandLineStatusReturned, ThreadOption.UIThread);

callback method is:

private void OnCommandLineStatusReturned(StatusMessageEventArgs args)
{
   //some data to display
}

now I have to publish this event two times with two different objects.

private StatusMessageEventArgs statusMessageEventArgs;
private StatusMessageEventArgs responsestatusMessageEventArgs;

I published these instances at different times,

EventAggregator.GetEvent<StatusMessageEvent>().Publish(statusMessageEventArgs);
EventAggregator.GetEvent<StatusMessageEvent>().Publish(responsestatusMessageEventArgs);

But when I run application, it misbehaves. i.e. out of 10 times, 2 times callback method doesn’t get invoked at all. is it because of 2 publish for same subscribe?

  • 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-07T21:18:54+00:00Added an answer on June 7, 2026 at 9:18 pm

    I got solution for this problem on following link:
    keepSubscriberReferenceAlive

    It says, If you are raising multiple events in a short period of time and have noticed performance concerns with them, you may need to subscribe with strong delegate references.

    By default, CompositePresentationEvent maintains a weak delegate reference to the subscriber’s handler and filter on subscription. This means the reference that CompositePresentationEvent holds on to will not prevent garbage collection of the subscriber. Using a weak delegate reference relieves the subscriber from the need to unsubscribe and allows for proper garbage collection.

    maintaining this weak delegate reference is slower than a corresponding strong reference. For most applications, this performance will not be noticeable, but if your application publishes a large number of events in a short period of time, you may need to use strong references with CompositePresentationEvent.

    I modified my subscribe method as follows.

    StatusMessageEvent>().Subscribe(OnCommandLineStatusReturned, ThreadOption.UIThread,true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly large application that uses WPF for its user interface. I
We have a .NET application which our customers consider too large for mass deployment
I have a large C#/WPF application. This application needs to collect data from other,
I am developing a large-ish application in WPF/WCF/NHibernate/etc. and have implemented the MVP pattern
I have a WPF Browser application, written in C#. In which have a process
I have a WCF client which passes Self-Tracking Entities to a WPF application built
I have a simple WPF application where I display one very large image (9000x2875)
I have a Custom control in WPF in which I define a large ItemsControl
I have a large WPF application that uses a large number of styles, brushes,
In a large WPF-project setting padding on buttons does not have any effect what

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.