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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:16:12+00:00 2026-06-03T05:16:12+00:00

In our application ,we use TPL to create tasks whenever we would want to

  • 0

In our application ,we use TPL to create tasks whenever we would want to make a service call.We have a busy indicator which is set to true whenever a task is started and cleared whenever the task is completed or faulted.Is there any way to accomplish this in a generic way instead of doing this for every single task created ?

First instance :

        ComponentViewModel.Instance.IsApplicationBusy = true;
        ComponentViewModel.Instance.BusyMessage = "Loading...";

        var task1 = Task.Factory.StartNew(() => DoTask1());
        task1.ContinueWith(antecdent =>
        {
            ComponentViewModel.Instance.IsApplicationBusy = false;
            CustomAction1();
        }

Second Instance :

        ComponentViewModel.Instance.IsApplicationBusy = true;
        ComponentViewModel.Instance.BusyMessage = "Loading...";

        var task2 = Task.Factory.StartNew(() => DoTask2());
        task2.ContinueWith(antecdent =>
        {
            ComponentViewModel.Instance.IsApplicationBusy = false;
            CustomAction2();
        }

the same is logic is repeated all through the application whenever a service call is made is there any way to avoid this repetition ?

For example there is a dragstarted and dragcompleted events which get fired for all drag operations , so it possible to have taskstarted and taskcompleted event possibly by extending the task factory or otherwise ?

Edit : Made changes so that the question is more clear.You can now observe that steps before starting and ending a task is same but different functions needs to be executed for each task when it runs to completion

  • 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-03T05:16:13+00:00Added an answer on June 3, 2026 at 5:16 am

    EDIT: It appears I’ve misunderstood the question. Creating this “start, wait, continue” as a centralized function is a good move, and could be created like this:

    public void DoIt(Action ThingToDo) {
        ComponentViewModel.Instance.IsApplicationBusy = true;
        ComponentViewModel.Instance.BusyMessage = "Loading...";
    
        var loadProviderTask = Task.Factory.StartNew(ThingToDo);
        loadProviderTask.ContinueWith(antecdent =>
        {
            ComponentViewModel.Instance.IsApplicationBusy = false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our application used to make use of a common base form that all forms
Sometimes in order to make our application more responsive and fast, we use client
OK, so we're writing our MFC application to make use of the built-in localization
Our android application is getting fairly big and we would like to use functional
I have to use Python and Django for our application. So, I have two
In our application we use jsf,we have to redirect the user to home page
We have common views that we use in our application in many locations inside
We have to introduce logging in our application. We have decided to use log4j
I am new in asp.net,I have to luanch our application use asp.net,and I use
I want to make application that will use GPS, as we know at first

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.