task

VS2013 Debug/Windows/Tasks: “No tasks to display”

☆樱花仙子☆ 提交于 2019-12-18 05:49:30
问题 I have Visual Studio Professional 2013 and I am debugging an application which uses async/await extensively. But when I stop at breakpoint and open Debug/Windows/Tasks window, it always says "No tasks to display." I've made two test, in one I can see task, in another I can't (I run program, and pause it). Or I can breakpoint at waiting fro task line. using System; using System.Threading; using System.Threading.Tasks; namespace TasksDebugWindowTest { class Program { static void Main(string[]

How to cancel and raise an exception on Task.WhenAll if any exception is raised?

懵懂的女人 提交于 2019-12-18 05:12:43
问题 I am waiting on multiples task using Task.WhenAll. When one of them generates an exception I would like Task.WhenAll (or any other way of awaiting multiples tasks) to immediately cancel the others tasks and raise an exception. Is it possible? Thanks in advance 回答1: Cancellation is coopertive the WhenAll can't cancel the threads but you can pass all of them a CancellationToken and fire the token when you get a exception. CancellationTokenSource cts = new CancellationTokenSource(); var task1 =

Gradle task replace string in .java file

本小妞迷上赌 提交于 2019-12-18 04:36:28
问题 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 to temp location while replacing lines > delete original file > copy duplicated file back to original place > delete temp file. Is there better solution? 回答1: May be you should try something like ant's replaceregexp: task myCopy << { ant

How should I update from Task the UI Thread?

﹥>﹥吖頭↗ 提交于 2019-12-18 04:12:22
问题 I have a task that performing some heavy work. I need to path it's result to LogContent Task<Tuple<SupportedComunicationFormats, List<Tuple<TimeSpan, string>>>>.Factory .StartNew(() => DoWork(dlg.FileName)) .ContinueWith(obj => LogContent = obj.Result); This is the property: public Tuple<SupportedComunicationFormats, List<Tuple<TimeSpan, string>>> LogContent { get { return _logContent; } private set { _logContent = value; if (_logContent != null) { string entry = string.Format("Recognized {0}

Find out whether celery task exists

跟風遠走 提交于 2019-12-17 23:05:16
问题 Is it possible to find out whether a task with a certain task id exists? When I try to get the status, I will always get pending. >>> AsyncResult('...').status 'PENDING' I want to know whether a given task id is a real celery task id and not a random string. I want different results depending on whether there is a valid task for a certain id. There may have been a valid task in the past with the same id but the results may have been deleted from the backend. 回答1: Celery does not write a state

How to cancel a running task?

风格不统一 提交于 2019-12-17 21:21:50
问题 I want to cancel a running task (when the users presses the escape key). when i click on "escape" key Form_KeyDown run but doesn't cancel task! CancellationTokenSource tokenSource = new CancellationTokenSource(); CancellationToken token=new CancellationToken(); private async void Search_Button_ClickAsync(object sender, EventArgs e) { token = tokenSource.Token; await (Task.Factory.StartNew(() => { //...my program }, token)); private void Form_KeyDown(object sender, KeyEventArgs e) { if (e

Keep running a specific number of tasks

这一生的挚爱 提交于 2019-12-17 20:30:50
问题 I have been trying to do this: Create 'N' Task to execute and keep running this number of taks for a period of time, in that case the one task finalize, then i should start a new task to keep the same number of task. I dont know if is this possible to handle with TaskScheduler or i have to create a custom TaskScheduler. Another option i think could work is , use TPL DataFlow Producer-Consumer when the task finish then taskscheduler take a new task generate by producer. The question is: how

Using AsyncTask to Send Android Email

六月ゝ 毕业季﹏ 提交于 2019-12-17 20:22:33
问题 I had recently asked a question regarding the following code: Sending Email in Android using JavaMail API without using the default/built-in app I had asked this in regards to a network error, as per a previous question: Need Help Debugging Email Code My question is, how would I implement an AsyncTask in order to successfully send an email with this Android code? Every tutorial that I see informs me that I should do extend AsyncTask { However, GMailSender.java already has this defined as:

C# task factory timeout

耗尽温柔 提交于 2019-12-17 18:54:58
问题 I have to execute a long process operation in a thread and continue by returning the result to a function. Here is my code : Task<ProductEventArgs>.Factory.StartNew(() => { try { // long operation which return new ProductEventArgs with a list of product } catch (Exception e) { return new ProductEventArgs() { E = e }; } }).ContinueWith((x) => handleResult(x.Result), TaskScheduler.FromCurrentSynchronizationContext()); The problem is actually I don't have a timeout. I want to put a timer in

Task.Run with Parameter(s)?

∥☆過路亽.° 提交于 2019-12-17 17:34:51
问题 I'm working on a multi-tasking network project and I'm new on Threading.Tasks . I implemented a simple Task.Factory.StartNew() and I wonder how can I do it with Task.Run() ? Here is the basic code: Task.Factory.StartNew(new Action<object>( (x) => { // Do something with 'x' }), rawData); I looked into System.Threading.Tasks.Task in Object Browser and I couldn't find a Action<T> like parameter. There is only Action that takes void parameter and no type . There are only 2 things similiar: static