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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:02:53+00:00 2026-06-04T07:02:53+00:00

I create windows form application using MVP design pattern. Example: IViewInterface view = new

  • 0

I create windows form application using MVP design pattern. Example:

IViewInterface view = new FormSome();
IPresenter presenter = new Presenter(view);

In presenter constructor I do something like this:

public Presenter( IViewInterface view ) {
    this.view = view;

    this.view.someEvens += myMethod;
}

Now my question:
What happens when I do something like this:

IViewInterface view;
{
    view = new FormSome();
    IPresenter presenter = new Presenter(view);
}
// if my presenter exists here? 

I don’t want to call any method from presenter explicitly. I only want to my presenter handle view’s event. Does GC remove my presenter from memory, or GC knows that my presenter handle view events, so as long as view exists, my presenter also will exist?

edit

I tested it and it works. But I’m not sure if it works because GC don’t destroy my presenter yet, or GC is more intelligent then I thought.

  • 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-04T07:02:54+00:00Added an answer on June 4, 2026 at 7:02 am

    The presenter will still remain “alive” as it is referenced through the event set here

    this.view.someEvens += myMethod;
    

    If the view is collected by the GC, the presenter is also destroyed.

    But please note that you do not have a reference to the presenter at the moment! You can not access it anymore after the code snipped you’ve posted.

    EDIT
    This, by the way, happened to be a problem for me when I thought I had destroyed all instances of a class, but they were still active because I had accidentially used them as event targets. I had TCP commands being handled even though they shouldn’t have been handled.

    That’s why I can tell that what you’re asking is actually the case 🙂

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

Sidebar

Related Questions

I am using data grid view in Windows Form standalone application to display items
In a windows application, you can create a new form and you can call
I'm using VB 2008 express to create a windows form application. I have a
Im using c# .net windows form application. I have many databases created using sql
Im using c# .net windows application form. I have created many databases with many
I'm trying to create a Windows Form application in C#, mostly just to practice
I have been tasked to create a form designer application in Windows Forms. The
I am new to C# and trying to learn how to create windows form
I tryed to create new components from one base Windows Form, also I found
I am working Windows form Application in c#.I like to create crystal report from

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.