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

I understand that the TPL does not necessarily create a new thread for every
In an Android application I run a task in a separate thread. While the
I seem to fail to create a foreground task. my main thread is supppose
I am getting following while doing ant build: Build\build.xml:247: Problem: failed to create task
Say I create a task bool aBoolean = true; Task.Factory.StartNew(() => while(aBooloean) { ...
I want to create Task in Google Calendar using Google Calendar API.Using C#. Looking
I have a content type Task, where we create task for ourself or user
What would it take to create a TASK card board with mappable states like
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

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.