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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:14:10+00:00 2026-05-31T23:14:10+00:00

I developed a class that compiles to a dll and my friend uses this

  • 0

I developed a class that compiles to a dll and my friend uses this dll and creates an instance of my class.

I want to do some action with my local variable when the user turns my friend’s program (GUI) off.

I tried destructor but it’s not deterministic.

My friend’s program doesn’t contain using and cannot compile this program again therefore I can’t use dispose method.

Any idea how to do it in another way?

thanks

I can’t use dispose like this :

using System;
using System.Text;

class Program
{
    static void Main()
    {
    // Use using statement with class that implements Dispose.
    using (SystemResource resource = new SystemResource())
    {
        Console.WriteLine(1);
    }
    Console.WriteLine(2);
    }
}

class SystemResource : IDisposable
{
    public void Dispose()
    {
    // The implementation of this method not described here.
    // ... For now, just report the call.
    Console.WriteLine(0);
    }
} 
  • 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-31T23:14:11+00:00Added an answer on May 31, 2026 at 11:14 pm

    Jon is correct, however, you could attempt a dirty work-around…

    You could wrap your friends application with another that, within the main method, calls his main method, then locate the main window (e.g. if it is a WPF application using Application.MainWindow) then sign up to that windows Closed event.

    You would still need to get the instance of your class. You could do this by adding a static list of instances to your class.

    This workaround is not something I’d highly recommend, but it could work.
    (Not recommended because it assumes access to your class ends as window closes.)

    If possible a bit better approach would to use the applications events and not the windows (WPF event and Winforms event).

    If the host application (that hosts your class) is really your friends, you could ask him to either change it, or, if he lost the code, for permission to recreate the code (using Reflector or a similar tool) and modify it.

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

Sidebar

Related Questions

I have recently developed some java applications that i want others to run on
I have a class of encryption that was developed in Microsoft Visual C++ 6.0,
I'm trying to develop a class that supports an asynchronus method invocation. This is
I developed a generic Unsigned class, or really a class template Unsigned<size_t N> that
I developed a control that uses the PDA's InputPanel to interact with the user.
I developed a DLL in Managed C++ which loads some plugins (implemented in any
I have developed a class in eclipse for my android application. Now I am
I have developed an utility class for spring which is a singleton which will
I have developed a Jersey Resource class. Can someone please tell me how can
I've developed a small helper function for a unit test class, which takes my

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.