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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:53:27+00:00 2026-05-11T02:53:27+00:00

The documentation of System.Threading.Timer says that I should keep a live reference for it

  • 0

The documentation of System.Threading.Timer says that I should keep a live reference for it to avoid it being garbage collected. But where should I do that? My main is very simple that I don’t know where to keep the reference:

class Program {     static void Main() {         new System.Threading.Thread(myThreadStart).Start();         new System.Threading.Timer(myTimerCallback, new MyStateObject(), 0, 5000);     } } 

I thought about keeping the reference in a static field in the Program class, assuming that static fields do not get collected until the end of the application. But I’m not sure this is the best way to do it, so I’d appreciate your advice.

  • 1 1 Answer
  • 3 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. 2026-05-11T02:53:28+00:00Added an answer on May 11, 2026 at 2:53 am

    If your Timer is an application-level object there’s nothing wrong with making it a private static member of your Main class. That’s what I would do, anyway.

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

Sidebar

Related Questions

To have a general-purpose documentation system that can extract inline documentation of multiple languages,
I can't find any documentation on implementing a class that inherits System.Windows.Media.Brush - what
The System.Threading.ConcurrentQueue.TryDequeue method threw an exception the other day that took me totally by
I have a ContentObserver registered to android.provider.Settings.System that should observe changes of any audio
The msdn documentation of the System.IDisposable interface states that The primary use of this
I have a web-based documentation searching/viewing system that I'm developing for a client. Part
The documentation says that if I already have virtualenv installed, then pip is available
I'm writing an app that will need to make use of Timer s, but
The documentation for System.nanoTime() says the following (emphasis mine). This method can only be
Is there a documentation system which is simple, will generate some friendly, hyperlinked documentation,

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.