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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:12:17+00:00 2026-06-03T02:12:17+00:00

i know i can get the Thread Name by calling Thread.CurrentThread.Name but i got

  • 0

i know i can get the Thread Name by calling Thread.CurrentThread.Name

but i got a tricky scenario.

i created two thread, each launch a new object (says objA) and run a method.

inside the object (objA) method (objAM), i create another object (says objB) and run a method (objBM).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;


namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            TESTA a = new TESTA();
        }

    }

    class TESTA
    {
        private Thread t;

        public TESTA()
        {
            t = new Thread(StartThread);
            t.Name = "ABC";
            t.IsBackground = true;
            t.Start();

            t = new Thread(StartThread);
            t.Name = "XYZ";
            t.IsBackground = true;
            t.Start();

        }

        private void StartThread()
        {
            objA thisA = new objA();
        }
    }

    class objA
    {
        private System.Threading.Timer t1;

        public objA()
        {
            objAM();
            t1 = new Timer(new TimerCallback(testthread), null, 0, 1000);
        }

        private void objAM()
        {
            Console.WriteLine("ObjA:" + Thread.CurrentThread.Name);
        }

        private void testthread(object obj)
        {
            objB thisB = new objB();
        }
    }

    class objB
    {
        public objB()
        {
            objBM();
        }

        private void objBM()
        {
            Console.WriteLine("ObjB:" + Thread.CurrentThread.Name);
        }
    }
}

but the value of Thread.CurrentThread.Name in objB return empty.

How can i get the Thread Name inside objBM?

  • 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-03T02:12:18+00:00Added an answer on June 3, 2026 at 2:12 am

    From description of System.Threading.Timer: The method does not execute on the thread that created the timer; it executes on a ThreadPool thread supplied by the system.

    Thus your testthread method executed on unnamed ThreadPool thread. Btw you can verify it by calling Thread.CurrentThread.IsThreadPoolThread.

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

Sidebar

Related Questions

I know I can get touch events in my iPhone app. But these touch
I know you can get the SQL, but it's paramterized without the parameters being
I know I can get answers here but I was wondering if anyone knows
I have created a thread so that I can get the current position of
I know that I can get word completion through CTRL+N & CTRL+P and code
I know that I can get a POSIX int file handle from NSURL by
Does anyone know how I can get the phone number of the device I
Does anyone know how I can get the helpful Eclipse popups with javadoc when
Does anyone know how I can get the value of an input box, without
Does anybody know where I can get a free web crawler that actually works

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.