task

Call task's updateProgress

房东的猫 提交于 2019-12-11 03:57:15
问题 I was reading the documentation for the class Task final Task<Void> task = new Task<Void>() { @Override public Void call() { for(int i=0;i<datesAndStudies.length;i++){ updateProgress(i,datesAndStudies.length); DoSomething something = new DoSomething(); something.VeryLongAndTimeConsumingMethod(i); } return null; } }; And I notice that updateProgress is protected and workdone/totalwork are both defined as public final ReadOnlyDoubleProperty . Is there a way/workaround to update/call

TPL Task deadlock when calling async from sync without await in MVC

旧城冷巷雨未停 提交于 2019-12-11 02:44:33
问题 I understand there's a TPL deadlock trap when calling async method within a sync MVC method, while using .Wait() or .Result to wait till the task complete. But we just found a strange behaviour in our MVC application: The sync action calls an async method, but since it's a trigger, we never waited it complete. Still, the async method seems stucked. Code is like below, this strange issue not 100% happens. It just happens sometime. When it happens: The HomeController.Index() action completed

What is the purpose of TaskExecutor in spring?

混江龙づ霸主 提交于 2019-12-11 02:36:36
问题 What is the purpose of TaskExecutor in spring. What problem does it solve ? How is it different from Executors in java concurrent package ? 回答1: From http://static.springsource.org/spring/docs/2.0.8/reference/scheduling.html 23.4. The Spring TaskExecutor abstraction ... Spring's TaskExecutor interface is identical to the java.util.concurrent.Executor interface. In fact, its primary reason for existence is to abstract away the need for Java 5 when using thread pools. The interface has a single

Why await an async function directly not work without assigning it to a Task variable

纵然是瞬间 提交于 2019-12-11 02:35:29
问题 Typically, I do the following public static async Task dosth() { List<Task> job = new List<Task>(); for (int i = 0; i < 3; i++) { job.Add(sleep()); } Task.WhenAll(job.ToArray()); } static async Task sleep() { await Task.Delay(1000); Console.WriteLine("Finish new"); } It works smoothly, no problem. But when I do a review on my own code (trying using other syntax to do the same job), I suddenly figure out the following two are different. public static async Task dosthA() { //This will be

Does async calling of web service make sense on server?

房东的猫 提交于 2019-12-11 02:24:26
问题 On my web server (ASP.NET MVC 4) I am calling web services (asmx) on another server. I have generated client from WSDL. There are sync methods and async methods (callbacks, not Tasks). I transform it to task oriented call (with TaskCompletionSource ) and then i call await like this: public async Task<DataObject> GetData() { var tcs = new TaskCompletionSource<DataObject>(); var client = new WebServiceClient(); client.GetDataCompleted += (sender, args) => tcs.SetResult(args.Result); client

Use of Pragmas in Ada

落花浮王杯 提交于 2019-12-11 01:48:52
问题 Can anyone supply me with simple working examples which illustrate the use of pragmas in Ada 2005 ? I understand that pragmas are used to priorities processes, just that I have not come across working examples ! Much appreciated ! 回答1: A search of comp.lang.ada for recent discussions about priorities has several interesting examples. This one seems particularly apropos to your question. Addendum: Two other exemplary sources are the Rationale for Ada 95 and Rationale for Ada 2005 回答2: An Ada

Getting user input in an elixir Task

喜欢而已 提交于 2019-12-11 01:04:50
问题 I'm trying to write a simple elixir program that is able to react to user input. My problem is that reading from stdio doesn't seem to work from Tasks. If my whole idea is silly please show me an example on how it's done. I can't find anything in the web I broke my problem down to a simple example: t = Task.async((fn->IO.gets "what?" end)) %Task{owner: #PID<0.65.0>, pid: #PID<0.80.0>, ref: #Reference<0.0.2.135>} The Task is started: iex(4)> pid=Map.get(t, :pid) #PID<0.80.0> iex(5)> Process

Duplicated tasks after time change

风格不统一 提交于 2019-12-11 00:53:24
问题 I don't know exactly why, but I am getting duplicated tasks. I thing this may be related with time change of the last weekend (The clock was delayed for an hour in the system). The first task should not be executed, since I say explicitly hour=2 . Any idea why this happens? [2017-11-01 01:00:00,001: INFO/Beat] Scheduler: Sending due task every-first-day_month (app.users.views.websites_down) [2017-11-01 02:00:00,007: INFO/Beat] Scheduler: Sending due task every-first-day_month (app.users.views

Why this prime number finding code is producing different results over iterations?

こ雲淡風輕ζ 提交于 2019-12-11 00:03:57
问题 I have a simple code that finds all prime numbers between 1 and 100000. The problem is, it's not precise. There are 9592 primes between 1 and 100000 but I'm getting values ranging from 9588 to 9592. The code is : List<bool> result = new List<bool>(); Stopwatch watch = Stopwatch.StartNew(); List<Task> tasks = new List<Task>(); for (ulong i = 1; i < 100000; i++) { tasks.Add(Task.Factory.StartNew(number => { var y = (ulong)number; if (y == 1) return false; if (y == 2) return true; for (ulong j =

Task cancellation exception not bubbling up when using async in method signature

人盡茶涼 提交于 2019-12-10 23:58:27
问题 I don't really understand this. In my code below, run as-is, the exception thrown by token.ThrowIfCancellationRequested() is not being sent back to where Main is using .Wait(), and is instead thrown on the spot with the stacktrace not really knowing where it happened other than "A task was cancelled". However if I remove the async keyword and remove the try catch block with the await Task.Delay(), it does get sent back to .Wait() in main and is caught there. Am I doing something wrong, or how