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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:23:54+00:00 2026-05-23T19:23:54+00:00

I am using the weak event manager in my WPF app to hook up

  • 0

I am using the weak event manager in my WPF app to hook up a source of an event to a target, using the XXXEventManager.AddListener(source, this); call. However, I have noticed that my code sometimes hooks up the same source and target more than once. This looks like it causes multiple events to be raised / handled that are effectively the same (i.e. one for each hook up). Is it possible to determine if the target is already hooked up to the event source by interrogating the WeakEventManager (or adding functionality to it) or will I have to implement my own list on the target?

Also, what’s the accepted method for calling RemoveListener if the event hook up should be present for the lifetime of the source? I’ve heard that using a finalizer is not good practice because it causes problems with garbage collection. Is this accurate?

  • 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-23T19:23:55+00:00Added an answer on May 23, 2026 at 7:23 pm

    Well you could check with GetInvocationList if the Eventmanager is already attached. Check if it is already attached with that manager with a specific target on the other hand i don’t know if thats possible. When looking at the PropertychangedEventManager though, it is perfectly fine to add multiple listeners to one manager with one target(distinguished with different property names)

    For me the correct way of calling RemoveListener is to use IDisposable. The problem with the finalizer is that your object lives longer, because it will be on the finalizer queue, and might get events at that time(not sure about that). Maybe this will help

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

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I'm making a MessageBox control in WPF using the MVVM pattern. This MessageBox will
Using online interfaces to a version control system is a nice way to have
I want to test my application on older iOS versions. I am using weak
We have a WPF application, based on Unity with MMVVVM pattern. In application life
I'm using a Dictionary with weak keys to test if an object has been
I'm trying to make a dynamic PDF form using Adobe LiveCycle designer and have
I have a problem with a memory leak in a .NET CF application. Using
When using weak events as described here http://wekempf.spaces.live.com/blog/cns!D18C3EC06EA971CF!373.entry in a Windows.Forms application the WeakEventManager
My SQL-fu is too weak for this, and I'm not even sure it's possible

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.