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
35
votes
5 answers

Have a set of Tasks with only X running at a time

Let's say I have 100 tasks that do something that takes 10 seconds. Now I want to only run 10 at a time like when 1 of those 10 finishes another task gets executed till all are finished. Now I always used ThreadPool.QueueUserWorkItem() for such task…
maddo7
  • 4,503
  • 6
  • 31
  • 51
34
votes
5 answers

Filter to show sub tasks of a filtered list of parent tasks

I have a JIRA filter which returns all the fixes in a future release: project = MyProject AND fixVersion = "1.1.1" and issuetype in standardIssueTypes() and status != Closed All of these issues have Sub-Tasks which I want to have in a new filter…
Shevek
  • 3,869
  • 5
  • 43
  • 63
34
votes
2 answers

C# async within an action

I would like to write a method which accept several parameters, including an action and a retry amount and invoke it. So I have this code: public static IEnumerable RunWithRetries(List source, int threads, Func> action, int…
Ori Refael
  • 2,888
  • 3
  • 37
  • 68
34
votes
4 answers

Gradle task replace string in .java file

I want to replace few lines in my Config.java file before the code gets compiled. All I was able to find is to parse file through filter during copying it. As soon as I have to copy it I had to save it somewhere - thats why I went for solution: copy…
Srneczek
  • 2,143
  • 1
  • 22
  • 26
33
votes
4 answers

How to make Task.WaitAll() to break if any exception happened?

I want to make Task.WaitAll() to break out if any of the running tasks throws an exception, so that I don't have to wait for 60 seconds to finish. How do I achieve such behavior? If WaitAll() cannot achieve that, is there any other c# feature or…
user926958
  • 9,355
  • 7
  • 28
  • 33
32
votes
4 answers

How to download s3 object directly into memory in java

Is it possible to download S3object in Java directly into memory and get it removed when i'm done with the task?
Manisha
  • 775
  • 6
  • 13
  • 30
32
votes
4 answers

Multi-threaded HttpListener with await async and Tasks

Would this be a good example of a scalable HttpListener that is multi-threaded? Is this how for example a real IIS would do it? public class Program { private static readonly HttpListener Listener = new HttpListener(); public static void…
halivingston
  • 3,727
  • 4
  • 29
  • 42
31
votes
3 answers

what is the correct way to cancel multiple tasks in c#

I have a button thats spawns 4 tasks. The same button changes to a cancel button and clicking this should cancel all 4 tasks. Should I pass the same cancel token to all 4 tasks and have them poll on the same token for IsCancelRequested ? I am…
Gullu
  • 3,477
  • 7
  • 43
  • 70
31
votes
3 answers

When to cache Tasks?

I was watching The zen of async: Best practices for best performance and Stephen Toub started to talk about Task caching, where instead of caching the results of task jobs you cache the tasks themselves. As far as i understood starting a new task…
Nikola.Lukovic
  • 1,256
  • 1
  • 16
  • 33
31
votes
2 answers

Gradle: Passing variable from one task to another

I want to pass a variable from one task to another, in the same build.gradle file. My first gradle task pulls the last commit message, and I need this message passed to another task. The code is below. Thanks for help in advance. task…
crystallinity
  • 431
  • 2
  • 6
  • 10
31
votes
2 answers

Asynchronous method that does nothing

I have an interface IAnimation which exposes a method BeginAsync(). That method should start the animation and return when it is completed. What I would like to do is implement a null animation class NoAnimation that just returns when it executes…
Fabio Marcolini
  • 2,315
  • 2
  • 24
  • 30
31
votes
2 answers

Threading.Tasks.Task' does not contain a definition for 'Result'

So i'm trying to learn how to program with Task's and i'm doing an exercise: public static int ReturnFirstResult(Func[] funcs) { Task[] tasks = new Task[funcs.Length]; for (int i = 0; i < funcs.Length; i++) { …
RSort
  • 501
  • 1
  • 5
  • 7
30
votes
9 answers

How to over-write the property in Ant?

Is there a way to re-assign the value for the Ant property task? Or is there another task available for that purpose?
Priya
29
votes
6 answers

How to pass LongRunning flag specifically to Task.Run()?

I need a way to set an async task as long running without using Task.Factory.StartNew(...) and instead using Task.Run(...) or something similar. Context: I have Task that loops continuously until it is externally canceled that I would like to set as…
Ryan
  • 579
  • 1
  • 6
  • 15
28
votes
2 answers

C# Async Task Method Without Await or Return

I have an Interface I that is implemented in two places like: interface I { Task DoSomething(); } The interface has async Task DoSomething method API that is then implemented in class A like: class A : I {....} class B : I {....} In class A,…
pixel
  • 9,653
  • 16
  • 82
  • 149