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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:10:07+00:00 2026-06-01T17:10:07+00:00

I have a question about timer in thread? My code : public partial class

  • 0

I have a question about timer in thread?

My code :

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
       Testing testing = new Testing();           
       Thread thread = new Thread(new ThreadStart(delegate
        {
            testing.Start();               
        }));
        thread.IsBackground = true;
        thread.Start();
    }


}

public class Testing
{
    System.Threading.Timer timer = null;

    public void Start()
    {
        if (timer == null)
            timer = new System.Threading.Timer(timerTick, null, 500, 500);
        List<ManualResetEvent> amanual = new List<ManualResetEvent>();
        for (int index = 0; index < 10; index++)
        {
            ManualResetEvent manual = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object context)
                {
                    this.RunningThreadPool(context);
                    manual.Set();
                }
                ));
            amanual.Add(manual);
        }

        WaitHandle.WaitAll(amanual.ToArray());
        Console.WriteLine("Task complete");
    }
    void timerTick(object sender)
    {            
        Console.WriteLine("Timer running");
    }

    public void RunningThreadPool(object context)
    {            
        Console.WriteLine("Thread in Threadpool is running...");           
    }
}

}

And this is result
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Thread in Threadpool is running…
Task complete
Timer running
Timer running
Timer running
Timer running

I have a question that how do timer run before threadpool executed. Except set timer on threadpool. Because i need timer check threads on threadpool.

  • 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-01T17:10:08+00:00Added an answer on June 1, 2026 at 5:10 pm

    I’d say that 500ms is quite enough time to complete your work queue, before the Timer even fires once. 10 Console.WriteLine calls doesn’t amount to much work.

    Assuming that you’re running a somewhat heavier workload:

    The Timer runs its callback in the ThreadPool, so it’s queued after the other work has been queued… i.e. It’s last in the queue. Because you are queueing more items than there are threads in the ThreadPool, and the ThreadPool only spins up new threads under prolonged load, the ThreadPool can’t execute the Timer’s callback in a timely fashion.

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

Sidebar

Related Questions

I have a question about the behaviour of Timer class in Java. This is
I have a question about using semaphores in cortex m3. I've found a thread
Refer below code public void acquire(){ synchronized(a){ print(acquire()); try{ //Thread.sleep(5000); synchronized(this){ wait(5000); } print(I
I have a small question about threading in Windows. I have the following code
I hava a Java mulithreading question. I have the following worker class: public class
This question about Timers for windows services got me thinking: Say I have (and
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body
I have a question about whether or not a specific way of applying of

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.