Questions tagged [task]

A task is an abstraction that is used to work with concurrency, it can denote operation that should be executed concurrently with the rest of a program. A task is a concurrent thread of execution in Ada and represents an asynchronous operation in .NET, also it corresponds to Threads in Java.

A task is an abstraction that is used to work with concurrency, it can denote operation that should be executed concurrently with the rest of a program.

  • Ada
    A task is a concurrent thread of execution in an Ada program. Task definitions are split into two parts - declaration and a body, which is mandatory. Task declaration defines entities exported from the task, whereas its body contains local declarations and statements of the task.

  • .NET
    Task is used to represents an asynchronous operation, it is a core concept of the which is used for asynchronous and parallel programming in the .NET framework.

  • C++
    future is used to represent an operation which may complete some time in the future. It helps programs achieve a degree of asynchrony where they may want/need to perform certain operations in parallel. std::async creates a task which may execute asynchronously, returning a std::future.

See also:

Related tags

8481 questions
24
votes
6 answers

Why would you want to use continueWith instead of simply appending your continuation code to the end of the background task?

The msdn documentation for Task.ContinueWith has only one code example where one task (dTask) runs in the background, followed by (using ContinueWith) a second task (dTask2). Essence of the sample shown below; Task dTask = Task.Factory.StartNew(…
snowcode
  • 1,033
  • 10
  • 24
24
votes
5 answers

Start a Task without waiting

I am using asp.net mvc and I want to cache some data about user from database when he reaches the home page of the site. So when user requests the Home page, I want to call an async method, which makes database calls and caches data. Any examples of…
user2873833
  • 263
  • 1
  • 2
  • 6
24
votes
3 answers

Combining many rake tasks into one rake task

Instead of running each rake task individually like this: rake db:drop rake db:create rake db:migrate rake db:load I want to run one rake task that does all for. This is what I have for my rakefile: desc 'This rebuilds development db' namespace…
Amir
  • 2,249
  • 7
  • 34
  • 48
23
votes
2 answers

Correct way to suspend coroutine until Task is complete

I've recently dove into Kotlin coroutines Since I use a lot of Google's libraries, most of the jobs is done inside Task class Currently I'm using this extension to suspend coroutine suspend fun awaitTask(task: Task): T = suspendCoroutine {…
Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86
23
votes
5 answers

How to create an efficient multi-threaded task scheduler in C++?

I'd like to create a very efficient task scheduler system in C++. The basic idea is this: class Task { public: virtual void run() = 0; }; class Scheduler { public: void add(Task &task, double delayToRun); }; Behind…
geza
  • 28,403
  • 6
  • 61
  • 135
23
votes
7 answers

Task vs. process, is there really any difference?

I'm studying for my final exams in my CS major on the subject distributed systems and operating systems. I'm in the need for a good definition for the terms task, process and threads. So far I'm confident that a process is the representation of…
Jens Kohl
  • 5,899
  • 11
  • 48
  • 77
23
votes
2 answers

Ruby: Accessing rake task from a gem without Rails

I'm aware that Rake tasks can be defined in a number of places within a Ruby gem: inside a Rakefile inside tasks/*.rake inside lib/tasks/*.rake I've read that the first two should be used when the tasks are to be executed on the gem itself. It…
KomodoDave
  • 7,239
  • 10
  • 60
  • 92
22
votes
4 answers

VScode: Defining own variables in tasks.json

I've set up a tasks.json file for building a project on multiple platforms. All platforms see the same content of the project repository. This is done either via disk sharing, because of running another platform in a VM, or via sync with the Git…
Jimmy Venema
  • 239
  • 1
  • 2
  • 5
22
votes
3 answers

Ignore the Tasks throwing Exceptions at Task.WhenAll and get only the completed results

I am working on a Task parallel problem that I have many Tasks that may or may not throw Exception. I want to process all the tasks that finishes properly and log the rest. The Task.WhenAll propage the Task exception without allowing me to gather…
Menelaos Vergis
  • 3,715
  • 5
  • 30
  • 46
22
votes
3 answers

.NET 4 Task Class Tutorial

.NET 4 has a Class - Task. It's pretty interesting and I would like to start using it. For example, I would like to create a very simple Task-based files downloader, with the ability to cancel with every download. Can anyone introduce me to some…
Lukas Šalkauskas
  • 14,191
  • 20
  • 61
  • 77
22
votes
4 answers

Display the time it takes each vagrant ansible task to complete

I'm converting a vagrant provisioner from shell to ansible and I was wondering if there's any option to show the actual time it takes to complete each task? Ideally I want to benchmark the difference between installing multiple packages in yum using…
Raath
  • 689
  • 1
  • 6
  • 21
22
votes
1 answer

How to a synchronize tasks?

Say I have an async method which saves to file: async Task SaveToFileAsync() { var file = await folder.GetFileAsync ( ...) var stream = file.OpenFileAsync(...) ///etc } Now imagine that SaveToFileAsync is called twice simultaneously. This…
user380719
  • 9,663
  • 15
  • 54
  • 89
21
votes
4 answers

Different summation results with Parallel.ForEach

I have a foreach loop that I am parallelizing and I noticed something odd. The code looks like double sum = 0.0; Parallel.ForEach(myCollection, arg => { sum += ComplicatedFunction(arg); }); // Use sum variable below When I use a regular…
Brian Triplett
  • 3,462
  • 6
  • 35
  • 61
21
votes
2 answers

What is the difference between WaitAll and WhenAll?

I have this code: List misClasificaciones = new List(); Task tskClasificaciones = Task.Run(() => { misClasificaciones =…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
21
votes
2 answers

Task unhandled exceptions

I'm trying to understand what is going on with exceptions that are thrown within a task object and never handled. On MSDN it said that: If you do not wait on a task that propagates an exception, or access its Exception property, the exception is…
user3101007
  • 691
  • 2
  • 7
  • 18