task

Constantly Update UI in Java FX worker thread

帅比萌擦擦* 提交于 2019-12-17 03:42:08
问题 I have Label label in my FXML Application. I want this label to change once a second. Currently I use this: Task task = new Task<Void>() { @Override public Void call() throws Exception { int i = 0; while (true) { lbl_tokenValid.setText(""+i); i++; Thread.sleep(1000); } } }; Thread th = new Thread(task); th.setDaemon(true); th.start(); However nothing is happening. I don't get any errors or exceptions. I don't need the value I change the label to in my main GUI thread so I don't see the point

Is Task.Factory.StartNew() guaranteed to use another thread than the calling thread?

半腔热情 提交于 2019-12-17 03:24:26
问题 I am starting a new task from a function but I would not want it to run on the same thread. I don't care which thread it runs on as long as it is a different one (so the information given in this question does not help). Am I guaranteed that the below code will always exit TestLock before allowing Task t to enter it again? If not, what is the recommended design pattern to prevent re-entrency? object TestLock = new object(); public void Test(bool stop = false) { Task t; lock (this.TestLock) {

How to safely call an async method in C# without await

戏子无情 提交于 2019-12-17 00:20:30
问题 I have an async method which returns no data: public async Task MyAsyncMethod() { // do some stuff async, don't return any data } I'm calling this from another method which returns some data: public string GetStringData() { MyAsyncMethod(); // this generates a warning and swallows exceptions return "hello world"; } Calling MyAsyncMethod() without awaiting it causes a "Because this call is not awaited, the current method continues to run before the call is completed" warning in visual studio.

Running tasks in sequence inside an infinite loop [closed]

假装没事ソ 提交于 2019-12-14 04:01:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I have a several tasks that are run in sequence; one after the other. Task.Factory.StartNew(() => DoWork1()) .ContinueWith((t1) => DoWork2()) .ContinueWith(t2 => DoWork3()); I want to put this inside a loop so they run indefinitely (After DoWork3() is done, go back to DoWork1() . I

task in verilog

做~自己de王妃 提交于 2019-12-14 03:59:50
问题 I am trying to write a task that gives a variable paddr diffrent values: module paddr1 ; task paddr1; input [10:0]paddr; input clock; @(posedge clock) begin paddr=10 #100; paddr=20; #100; paddr=30; #100; paddr=40; #100; paddr=50; #100; paddr=60; #100; paddr=70; #100; paddr=80; #100; end endtask endmodule I tried to call this task from test bench and wrote: paddr1 (paddr,clock); It passes compilation But when I'm trying to run simulation I get an eror massage: Unresolved reference to 'paddr1'.

How can I further reduce my Apache Spark task size

懵懂的女人 提交于 2019-12-14 03:49:32
问题 I'm trying to run the following code in scala on the Spark framework, but I get an extremely large task size (8MB) tidRDD:RDD[ItemSet] mh:MineHelper x:ItemSet broadcast_tid:Broadcast[Array[ItemSet]] count:Int tidRDD.flatMap(x => mh.mineFreqSets(x, broadcast_tid.value, count)).collect() The reason I added the MinerHelper class was to make it serialisable, and it only contains given method. An ItemSet is a class with 3 private members and a few getter/setter methods, nothing out of the ordinary

Using await inside a ContinueWith() block

与世无争的帅哥 提交于 2019-12-14 03:47:15
问题 I have the following code: var result = MessageBoxHelper.MsgBox .ShowAsync("Press Yes to proceed", MessageBoxButton.YesNo) .ContinueWith((answer) => { if (answer.Result == MessageBoxResult.Yes) { Task<bool> asyncTask = ExecuteAsyncFunc(); //asyncTask.Unwrap(); ?? asyncTask.ContinueWith((a) => { // More }, TaskContinuationOptions.OnlyOnRanToCompletion); } }, TaskContinuationOptions.OnlyOnRanToCompletion); } Invoked elsewhere like this: public async Task<bool> ExecuteAsyncFunc() { await

TPL: check if task was faulted in OnCompleted event

*爱你&永不变心* 提交于 2019-12-14 03:35:16
问题 I have a task like: var migrateTask = Task.Run(() => { //do stuff }); migrateTask.ConfigureAwait(true).GetAwaiter().OnCompleted(this.MigrationProcessCompleted); How to tell in the method MigrationProcessCompleted if I got an exception or task was faulted in the initial thread (in do stuff code block)? Is there a way to find this without making the task a class member/property? 回答1: You should never be really calling .GetAwaiter() it is intended for compiler use. If you can use await your code

How to wait for async void to complete?

北城以北 提交于 2019-12-14 03:28:10
问题 i need to wait for my async void to finish. It has some await Task.Delay functions in it and I need them to finish before it continues. This void doesn't return anything so I don't see a reason to make it async Task<> and I also shuffle an array inside this void and I declare some variables. So how can I do this ? Is async Task<> the only way ? My void is not expecting any parameters/inputs. 回答1: Return Task (not Task<T>) instead of void . Note, the non-generic form of Task does not need to

How can I create and integrate Human Task into BPEL Workflow using WSO2 BPS?

自作多情 提交于 2019-12-14 02:44:01
问题 I'm trying to create and integrate Human Task into BPEL workflow. So far I've found only one sample of human task integrated with WSO2 BPS but it doesn't show how to create it, it's just ready to deploy and execute. Does anyone know if WSO2 has recently released new tools/methods to create and integrate Human Task into BPEL? 回答1: Please refer to the following blog posts and articles they might help with your work http://nandikajayawardana.blogspot.com/2013/05/how-to-implement-your-own-task-ui