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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:49:49+00:00 2026-06-07T07:49:49+00:00

Long-running tasks are usually executed in a background thread to keep the UI from

  • 0

Long-running tasks are usually executed in a background thread to keep the UI from freezing. It seems the threading logic could reside in either the view or in the controller.

As an example (in C#), suppose there is a method named RunAsync that runs a delegate in a background thread, here are two ways of doing it:

// Option 1

public class View {
  public void OnButtonClicked() {
    RunAsync(() => controller.DoSomething());
  }
}

public class Controller {
  public void DoSomething() {
    model.Foo();
  }
}

or:

// Option 2

public class View {
  public void OnButtonClicked() {
    controller.DoSomething();
  }
}

public class Controller {
  public void DoSomething() {
    RunAsync(() => model.Foo());
  }
}

Is there an advantage to doing it one way or the other?

  • 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-07T07:49:51+00:00Added an answer on June 7, 2026 at 7:49 am

    I see two arguments for the Controller having the responsibility for Thread safety.

    1. The controller is (at least conceptually) reusable by many views. We avoid repeating ourselves but putting the RunAsync() in the Controller rather than in many Views.
    2. Only the Controller really “knows” whether any such threading is needed. Indeed we might change the controller in future. So we have a “single responsibility” way of thinking. The controller both decides whether RunAsynch() is needed and actualy makes sure it is done.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our Swing application performs some long-running tasks in a background thread using the excellent
In the past, orientation changes and AsyncTask (and other long running background tasks) have
I got started with threads Thread.Start() recently and Long Running Tasks and noticed several
I am writing an application to allow users to schedule one-time long-running tasks from
Background tasks being stuff that involves network I/O, disk I/O, or other long-running tasks
I am using System.Threading.Tasks to execute my long running service calls and using ContinueWith
I'm designing a framework for managing certain api calls and other long-running tasks on
I am running into OutOfMemoryError on a long running background process on Glassfish. Memory
Good day, I have a gen_server process which does some long-running state-updating tasks periodically
I'm using gearman to distribute long running tasks across multiple worker servers. For one

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.