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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:09:31+00:00 2026-05-31T10:09:31+00:00

I seem to fail to create a foreground task. my main thread is supppose

  • 0

I seem to fail to create a foreground task.
my main thread is supppose to call another thread and then exit.
the other thread suppose to run forever

void MainThreadMain()
{
    task_main = Task.Factory.StartNew(() => OtherThread()) ;
    return;
}

void OtherThread()
{
  while(true)
  {
     TellChuckNorrisJoke();
  }
}

how can I ensure task_main will continue running even that Main Thread is dead?
I assumed il do:

task_main.IsBackgorund = false; 

but no such option :\
I can make my main thread to wait a signal from my other thread that it passed to Foreground mode. but thats plain silly.

  • 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-31T10:09:32+00:00Added an answer on May 31, 2026 at 10:09 am

    The obvious question is: why don’t you run your work on the main thread?

    Assuming this is not an option, you should use a Thread not a Task. Then you can set:

    Thread.IsBackground = false;
    

    This will prevent your application from terminating while the worker thread is running.

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

Sidebar

Related Questions

Seem to run into a service endpoint not found problem when trying to get
The following PHP script fails to create the directory. It will also fail to
Seem to be having some issues storing the current date in a core data
There seem to be very different opinions about using transactions for reading from a
I seem to be having a very frustrating time with an inherited class calling
I seem to remember there is a problem with WITH. I don’t miss it;
There seem to be a limitation in the maximum number of clickable options in
I seem to have a problem with getting MVC to fill in my custom
It seem that my USB -> parallel port converter(SUNIX ComHUB) don't show as parallel
There seem to be no property for an image to use at all, even

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.