How to over-write the property in Ant?

ant-contrib’s Variable task can do this: <property name=”x” value=”6″/> <echo>${x}</echo> <!– will print 6 –> <var name=”x” unset=”true”/> <property name=”x” value=”12″/> <echo>${x}</echo> <!– will print 12 –> Not recommended, though, it can lead to weird side-effects if parts of your Ant scripts assume immutable property values, and other parts break this assumption.

When to cache Tasks?

I have trouble understanding how this actually helps more than just storing the results. When a method is marked with the async modifier, the compiler will automatically transform the underlying method into a state-machine, as Stephan demonstrates in previous slides. This means that the use of the first method will always trigger a creation of … Read more

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

Yeah, what you said about using a single CancellationToken is correct. You can create a single CancellationTokenSource and use its CancellationToken for all of the tasks. Your tasks should check the token regularly for cancellation. For example: const int NUM_TASKS = 4; CancellationTokenSource cts = new CancellationTokenSource(); CancellationToken ct = cts.Token; Task[] tasks = new … Read more

Multi-threaded HttpListener with await async and Tasks

I’ve done something similar at https://github.com/JamesDunne/Aardwolf and have done some extensive testing on this. See the code at https://github.com/JamesDunne/aardwolf/blob/master/Aardwolf/HttpAsyncHost.cs#L107 for the core event loop’s implementation. I find that using a Semaphore to control how many concurrent GetContextAsync requests are active is the best approach. Essentially, the main loop continues running until the semaphore blocks the … Read more

Threading.Tasks.Task’ does not contain a definition for ‘Result’

You’re returning Task from the CreatingTask method – you need to return Task<int>, and then change tasks to be Task<int>[] instead of Task[]. Basically, Task represents a task which doesn’t produce a result – whereas Task<T> represents a task producing a result of type T. In your case, everything throughout your code returns int, so … Read more

Asynchronous method that does nothing

Just use Task.CompletedTask to return a completed task: public Task BeginAsync() { return Task.CompletedTask; } If you have a Task<TResult> use Task.FromResult<TResult> to return a completed task with a result: public Task<bool> BeginAsync() { return Task.FromResult(true); } Your current implementation is very inefficient, as it builds the state machine, and also uses a ThreadPool thread … Read more

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

The following should do it without altering the code of the original tasks (untested): static bool WaitAll(Task[] tasks, int timeout, CancellationToken token) { var cts = CancellationTokenSource.CreateLinkedTokenSource(token); var proxyTasks = tasks.Select(task => task.ContinueWith(t => { if (t.IsFaulted) cts.Cancel(); return t; }, cts.Token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Current).Unwrap()); return Task.WaitAll(proxyTasks.ToArray(), timeout, cts.Token); } Note it only tracks faulted tasks … Read more

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

You can install the Craftforge JQL functions https://plugins.atlassian.com/plugin/details/31601 You then create a filter project = MyProject AND fixVersion = “1.1.1” and issuetype in standardIssueTypes() and status != Closed Call this filter for example ‘parentIssues’ Using the JQL issue in subtaskIssuesFromFilter(“parentIssues”) will retrieve all relevant subtask issues.