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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:19:59+00:00 2026-05-25T16:19:59+00:00

A: new Thread(new ThreadStart(ListenForResponse)) { IsBackground = true }.Start(); B: ThreadStart threadStart = new

  • 0

A:

new Thread(new ThreadStart(ListenForResponse)) { IsBackground = true }.Start();

B:

ThreadStart threadStart = new ThreadStart(ListenForResponse);

Thread listeningThread = new Thread(threadStart);

listeningThread.IsBackground = true;

listeningThread.Start();

As far as I can tell they are functionally equivalent. I’m just wondering which is preferred. Which would you rather see in a project?

  • 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-25T16:20:00+00:00Added an answer on May 25, 2026 at 4:20 pm

    I prefer this:

    Thread listeningThread = new Thread(new ThreadStart(ListenForResponse))
    {
        IsBackground = true
    }
    
    listeningThread.Start();
    

    This question is quite subjective, though.

    If you are setting more parameters on the various objects, the one-liner version starts to get hard to read.

    On the other hand, writing everything out explicitly for the simple case can be wordy and clutter the meaning of what’s going on.

    Also, a personal pet peeve is putting a function call waaay at the end of the line, where it is hard to see, as in your first example.
    Even if you want to use that syntax, I would prefer to see the .Start() on its own line.

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

Sidebar

Related Questions

Here is my code: ThreadStart threadStart = controller.OpenFile; Thread thread = new Thread(threadStart); thread.Start();
Or is it okay to do something like this: new Thread( new ThreadStart( delegate
If i use thread like this: void foo() { new Thread().Start(); } since the
Given the code: new Thread(new BackgroundWorker()).start(); Intuitively it feels like the BackgroundWorker instance should
I want to start a new thread using a C function, not an objective-C
Consider the below program myThread = new Thread( new ThreadStart( delegate { Method1(); Method2();
I'm just trying to run a new thread each time a button click even
What is the difference between: new Thread(new ThreadStart(SomeFunc)) and: new Thread( delegate() { SomeFunc();}
If I have code like this: try { Thread t = new Thread(new ThreadStart(wc.LocalRunProcess));
I have such code in my app: var t = new Thread(new ThreadStart(new Action(SomeClass.SomeMethod)));

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.