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

  • Home
  • SEARCH
  • 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 9161287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:56:04+00:00 2026-06-17T13:56:04+00:00

I have the following job sent to multiple threads for processing from main UI

  • 0

I have the following job sent to multiple threads for processing from main UI thread.
Upon completion of all jobs, I need to issue a message “Job completed” to let the user know it’s done.

LimitedTaskScheduler scheduler = new LimitedTaskScheduler(4);
TaskFactory factory = new TaskFactory(scheduler);
MessageBox.Show("Job started");
for (int i = 0; i < rows.Length; i++)
{
  string tabName = rows[i]["TableName"].ToString();
  int nStatus;
  factory.StartNew<int>(() =>
  {
   nStatus = ProcessTable(tabName);
   return nStatus;
  });
}
MessageBox.Show("Job finished");

In the above code, MessageBox.Show(“Job finished”); is executed immediately after the the tasks are sent, which is wrong.
If I use Task.WaitAll(); it will lock up the main UI thread which I don’t want it to.

My question is what is the best way to display “Job finished” message after all tasks are completed while not locking up the main UI thread?

Thanks in advance.

  • 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-17T13:56:05+00:00Added an answer on June 17, 2026 at 1:56 pm

    If you need only to notify users, just create a continuation for the task but pass the TaskScheduler which you get by the call TaskScheduler.FromCurrentSynchronizationContext in UI thread.

    This continuation will be executed in UI thread after parent task is completed.

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

Sidebar

Related Questions

I have the following regex: s/\\/\\\\/g This does a nice job of replacing all
I have the following models Models Job belongs_to :company Company has_many :jobs Right now
I have following function which is called continuously from run() of a Thread which
I have the following models class Person(models.Model): name = models.CharField(max_length=100) class Employee(Person): job =
I have just started using jQuery and although following code gets the job done,
I have an json output of the following (ignore the escape characters) {\sEcho\:1,\iTotalRecords\:10,\iTotalDisplayRecords\:10,\aaData\:[{\Job\:\developer\,\Name\:\kurt\},{\Job\:\plumber\,\Name\:\john\}]} which
I have following script that executes all the .reg files in the current directory.
I have the following script. The created background job never finishes. (It finishes in
I have following Spring job to run after every 30 minutes. Please check my
I have following problem: on my Jenkins 1.438 I have job with maven 3

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.