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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:13:44+00:00 2026-05-23T04:13:44+00:00

Quote from C# language specification 3.9: ‘2. If the object, or any part of

  • 0

Quote from C# language specification 3.9:

‘2. If the object, or any part of it, cannot be accessed by any possible
continuation of execution, other than
the running of destructors, the object
is considered no longer in use, and it
becomes eligible for destruction…

For instance would the DispatcherTimer be eligible for garbage collection before the Tick event fires?

    public void DispatchCallbackAfter(Action callback, TimeSpan period)
    {
        DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Normal, AppSettings.MainWindow.Dispatcher);
        timer.Tick += new EventHandler(DispatchCallback);
        timer.Interval = period;
        timer.Tag = new object[] {timer, callback};
        timer.Start();
    }

    private void DispatchCallback(object sender, EventArgs args)
    {
        DispatcherTimer t = (DispatcherTimer)sender;
        t.Stop();
        ((Action)((object[])t.Tag)[1])();
    }

NOTE: There is self reference to the timer in timer.Tag but I imagine that would not make any difference?

  • 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-23T04:13:45+00:00Added an answer on May 23, 2026 at 4:13 am

    While the DispatcherTimer is running, the Dispatcher has a reference to it, and it will not get GCed. Once the timer stops and there is no external reference to it, it can be collected. That is, if your only references to the timer and the callback are within the timer and the callback, and the timer is stopped, the timer can be collected.

    You can tell that the dispatcher takes a reference to a running timer by looking in Reflector (or your favorite decompiler) and seeing that the timer calls _dispatcher.AddTimer(this); in its start function and _dispatcher.RemoveTimer(this); in its stop function.

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

Sidebar

Related Questions

Quote from Jason Coco it not possible to set multiple in UILabel... but how
I want remove "Language" querystring from my url. How can I do this? (using
Quote from Wikipedia : A public key token. This is a 64-bit hash of
Quote from Head first html: You can add padding to the top and bottom
Quote from hib official docs: Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method.
I would like to trim a beginning and ending double quote () from a
For example, mysql quote table name using SELECT * FROM `table_name`; notice the `
Do you know of any "JSON Beautifier" for JavaScript? From {"name":"Steve","surname":"Jobs","company":"Apple"} To { "name"
And I quote from MSDN http://msdn.microsoft.com/en-us/library/aa366533(VS.85).aspx : The malloc function has the disadvantage of
From http://code.google.com/p/unladen-swallow/wiki/ProjectPlan I quote: Using a JIT will also allow us to move Python

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.