task

Why does Task.WhenAll return void?

蓝咒 提交于 2019-12-10 10:58:06
问题 This is the code from the image above: if (claims != null && claims.Any()) { // firstly, why doesn't this work? // var _claimResults = from claim in claims select UserManager.AddClaimAsync(user.Id, claim); // but this does... List<Task> _claimResults = new List<Task>(); foreach (var claim in claims) { _claimResults.Add(UserManager.AddClaimAsync(user.Id, claim)); } // secondly, why does Task.WhenAll return void when it clearly says it returns Task? Task claimsResult = await Task.WhenAll(

How can I not include a build task when I include a project in my settings.gradle file?

依然范特西╮ 提交于 2019-12-10 10:45:50
问题 My settings.gradle file looks like: include "serverTest", "shared" And the serverTest build.gradle file looks like: group = 'gradle' version = '1.0' defaultTasks 'build' apply plugin: 'java' apply plugin: 'eclipse' sourceCompatibility = JavaVersion.VERSION_1_6 dependencies { compile project(':shared') } The directory structure is: The top level holds the settings.gradle file and it has folders shared and serverTest in it. Then in the serverTest directory there is the build.gradle file. When I

Top Level Task Causes Error “The current SynchronizationContext may not be used as a TaskScheduler.” [duplicate]

▼魔方 西西 提交于 2019-12-10 10:00:27
问题 This question already has answers here : The current SynchronizationContext may not be used as a TaskScheduler (3 answers) Closed 4 years ago . I do not see the answer yet, although I have looked on stackoverflow and documentation. This error is coming up over the ContinueWidth below if I call the code that creates the tasks from a timer handler or within another task. For example, if it is wrapped in another task that creates tasks every interval (e.g. every 1 second) as follows. The only

How to make an application crash when a Task throws an exception without waiting the finalizer

最后都变了- 提交于 2019-12-10 04:33:17
问题 We are using Tasks in our .Net 4 (no async await available) application and sometimes they are used to launch 'Fire and Forget' operations like the following one: private void Test() { Task task = Task.Factory.StartNew(() => { throw new ApplicationException("Test"); }); } We want this exception to crash the application without waiting the task (as otherwise it makes no sense to have it in a task, at least in our scenarios) and without waiting the finalizer as we want to shutdown the

How to check that all tasks have been properly completed?

依然范特西╮ 提交于 2019-12-10 03:52:05
问题 I have the following lines in my code: var taskA = Task.Factory.StartNew(WorkA); var taskB = Task.Factory.StartNew(WorkB); var allTasks = new[] { taskA, taskB }; Task.Factory.ContinueWhenAll(allTasks, tasks => FinalWork(), TaskContinuationOptions.OnlyOnRanToCompletion); But when I run this, I get the following error: It is invalid to exclude specific continuation kinds for continuations off of multiple tasks. Which is caused by the option TaskContinuationOptions.OnlyOnRanToCompletion . My

The taskdef ant task cannot be found

不羁岁月 提交于 2019-12-10 02:42:01
问题 All - I'm following the most simplest instructions on this page: http://ant.apache.org/manual/develop.html However, when I try to execute the target "main" I get this error in netbeans: taskdef class dec102012.MyAntTask cannot be found using the classloader AntClassLoader[] But this error does not make sense because my new Java class that extends "Task" looks like this: package dec102012; import org.apache.tools.ant.BuildException; public class MyAntTask extends org.apache.tools.ant.Task{

Multiple Tasks JavaFX

天大地大妈咪最大 提交于 2019-12-10 00:28:56
问题 I've been searching for some time now on how to create multiple tasks and have them run one after the other. Here is the java code: public class Main extends Application { DropShadow shadow = new DropShadow(); Button button = new Button("Start"); Task<Integer> task; Task<Integer> task2; Label label1 = new Label("Status: NOT STARTED"); ProgressBar bar = new ProgressBar(0); ProgressIndicator pi = new ProgressIndicator(0); Thread th = new Thread(); public void start(Stage stage) { task = new

Bring task to front on widget click

落花浮王杯 提交于 2019-12-09 23:46:05
问题 I sent a task (activity) to back with: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); moveTaskToBack(true); } but I need bring it to front by setOnClickPendingIntent in widget. 回答1: Just start the main (root) activity of your application like this: Intent intent = new Intent(context, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); If the

Getting the Tasks in a Google App Engine TaskQueue

别等时光非礼了梦想. 提交于 2019-12-09 18:01:38
问题 I know you can view the currently queued and running tasks in the Dashboard or development server console. However, is there any way to get that list programmatically? The docs only describe how to add tasks to the queue, but not how to list and/or cancel them. In python please. 回答1: It sure doesn't look that way. Instead of removing the task, how about altering the task handler, whatever it is that handles the task url invokes, to check to see if the work specified still needs to be done,

How to determine whether Task.Run is completed within a loop

佐手、 提交于 2019-12-09 16:32:10
问题 This may be an odd question and it is really for my educational purpose so I can apply it in future scenarios that may come up. I am using C#. I am stress testing so this is not quite production code. I upload data to my server via a web service. I start the service off using a Run.Task. I check to see if the Task is completed before allowing the next Run.Task to begin. This is done within a loop. However, because I am using a modular declared Task will not the result be affected? I could