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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:20:41+00:00 2026-05-26T06:20:41+00:00

When you create a Task while specifying TaskCreationOptions.LongRunning a new thread is created specifically

  • 0

When you create a Task while specifying TaskCreationOptions.LongRunning a new thread is created specifically for the task. If you do not specify the TaskCreationOptions.LongRunning then the threadpool is used.

Please correct me if I’m wrong but if the threadpool is used you do not need to dispose() the task (as long as you have not used any synchronisation objects inside the task, like Wait() on a child task).

If this is the case, am I responsible for cleaning up the extra thread created by using the TaskCreationOptions.LongRunning flag?

If so is the following an acceptable pattern:

var task = Task.Factory.StartNew(() => {...}, TaskCreationOptions.LongRunning);

task.ContinueWith(x => task.Dispose());

Notice how, the ContinueWith does not have a TaskContinuationOptions.LongRunning, so it should use the threadpool.

That being said, however, I have read that the thread that moves the state of the task to Completed, Faulted or Cancelled has a high change of running the continuation.

If someone could shine some light on this I would really appreciate it.

  • 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-26T06:20:42+00:00Added an answer on May 26, 2026 at 6:20 am

    TaskContinuationOptions.LongRunning is a hint to the Task factory/scheduler, things are not so fixed as you portray it.

    I would expect the ContinueWith to be executed on the same (longRunning) Thread, that may or may not be running on the ThreadPool.

    And as far as I know cleanup of Tasks is automatic, so I wouldn’t bother with Dispose() here.

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

Sidebar

Related Questions

In an Android application I run a task in a separate thread. While the
I want to create Task in Google Calendar using Google Calendar API.Using C#. Looking
is there a way to create a task/activity report (say a weekly report) off
Is there some way to use schtasks to create a task with multiple schedules
I am trying to figure out how to accomplish the following task: Create a
I've been given the task to create a simple Silverlight chat box for two
What is the preferred way to create a background task for a Rails application?
I am trying to use the axis-java2wsdl ant task to create a wsdl from
My task is to create a simple web browser in Java. So far it
I want to create a custom MSBuild task that changes my .cs files before

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.