task

How reliable is windows task scheduler for scheduling code to run repeatedly?

a 夏天 提交于 2019-12-05 09:05:08
I have a bit of code that needs to sit on a windows server 2003 machine and run every minute. What is the recommended way of handling this? Is it ok to design it as a console service and just have the task scheduler hit it ever minute? (is that even possible?) Should I just suck it up and write it as a windows service? Since it needs to run every single minute, I would suggest writing a Windows Service. It is not very complicated, and if you never did this before, it would be great for you to learn how it is done. Calling the scheduled task every minute is not something I would recommend. I

How to find which method 'hangs' with async/await?

匆匆过客 提交于 2019-12-05 09:03:41
In the 'old' times it was very easy to track which method is hanging: just go to debugger, hit 'pause' button and go through stack traces. Now however, if the problem is in the async method, this approach does not work - since the next piece of code to execute is buried somewhere in the continuation tasks (technically it does not even hang)... Is there a way for such easy debugging with tasks? UPD. Example: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { await DoHolyWar();

How may I resolve this error? - Delegate 'System.Action<object>' does not take 0 arguments

浪子不回头ぞ 提交于 2019-12-05 08:55:27
The following code: var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { listBox1.Items.Add("Starting to crawl " + srMainSiteURL + "..."); } , ui); is resulting in the following error: Delegate 'System.Action<object>' does not take 0 arguments After looking at other threads, I have not been able to determine nor understand the cause of the error. Please advise. Alois Kraus Because you did use public Task StartNew(Action<object> action, object state) I do think you wanted to use public Task StartNew(Action action, CancellationToken cancellationToken,

JavaFX: How can I use correctly a ProgressIndicator in JavaFX

雨燕双飞 提交于 2019-12-05 08:49:31
I´m newbe in JavaFX. I have a problem with my JavaFX application, I need to start my ProgressIndicator (type INDETERMINATE) before a database query. This is part of my code: spinner.setVisible(true); passCripto = cripto.criptoPass(pass); MyDao dao = new MyDaoImpl(); boolean isLoginOk = dao.isUserOk(user, passCripto); boolean isStatusOk = dao.idStatusUser(user); When finished, I need to set spinner to FALSE but the spinner only is showed when database query is finished. How can I solve this ? Thanks. I do this, but not resolved: Task<Boolean> taskValidaLogin = new Task<Boolean>() { @Override

SpringCloud(第 047 篇)注解式Async配置异步任务

半世苍凉 提交于 2019-12-05 07:41:03
SpringCloud(第 047 篇)注解式Async配置异步任务 一、大致介绍 1、有时候我们在处理一些任务的时候,需要开启线程去异步去处理,原有逻辑继续往下执行; 2、当遇到这种场景的时候,线程是可以将我们完成,然后在SpringCloud中也有这样的注解来支撑异步任务处理; 二、实现步骤 2.1 添加 maven 引用包 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>springms-async</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <parent> <groupId>com.springms.cloud</groupId>

Execute repository functions in scheduler task

让人想犯罪 __ 提交于 2019-12-05 07:19:38
Currently I have an scheduler task, but I want to use function from my extbase repository (in the same extension). I keep getting "PHP Fatal error: Call to a member function add() on a non-object", no matter how I try to include my repo or controller from extbase. My SampleTask.php: namespace TYPO3\ExtName\Task; class SampleTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask { public function execute() { $controller = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\TYPO3\ExtName\Controller\SampleController'); $new = new \TYPO3\ExtName\Domain\Model\Sample; $new->setName('test');

Gradle create multi project Jar

让人想犯罪 __ 提交于 2019-12-05 06:22:23
问题 So I've been playing in Gradle and Android Studio now since the early days of their inception. However, I find myself banging my head on the walls far more times then it is worth at times :(. I have spent a day and a half trying to resolve my current dilemma. Where I work we use a lot of shared library projects. This means that unlike Gradle's native assumption, my projects are NOT all nested under one parent project. (BUT this is NOT my question) I have gotten this working. After our

How to solve: Custom MSBuild task requires assembly outside of AppBase

◇◆丶佛笑我妖孽 提交于 2019-12-05 06:16:27
I have a custom Task that I want to execute when building my C# projects. This task is located in MyTask.dll, which references another assembly, MyCommon.DLL. The problem is that MyCommon.dll is located at "..\Common\MyCommon.dll" relative to MyTask.dll, which puts it outside the AppBase dir for MSBuild process. I've confirmed that this is indeed the problem by analyzing MSBuild's log and seeing Fusion's report about the binding failure. What can I do to make Fusion find MyCommon.dll during the build process? Note that moving the assembly would break my app, which also depends on it. UPDATE:

Creating and starting a task on the UI thread

*爱你&永不变心* 提交于 2019-12-05 05:51:47
When a method that gets called on a worker thread needs to run code on the UI thread and wait for it to complete before doing something else, it can be done like this: public int RunOnUi(Func<int> f) { int res = Application.Current.Dispatcher.Invoke(f); return res; } But what if I wanted to do it with tasks? Is there a way for the RunOnUi method to create a task that is started on the UI and return it so that the caller (which runs on a worker thread) can wait for it? Something that will fit the following signature: public Task<int> StartOnUi(Func<int> f) ? One way to do it is as follows:

How to start async Task objects

荒凉一梦 提交于 2019-12-05 05:46:04
问题 I want to start a collection of Task objects at the same time and wait until all are complete. The following code shows my desired behaviour. public class Program { class TaskTest { private Task createPauseTask(int ms) { // works well return Task.Run(async () => // subsitution: return new Task(async () => { Console.WriteLine($"Start {ms} ms pause"); await Task.Delay(ms); Console.WriteLine($"{ms} ms are elapsed"); }); } public async Task Start() { var taskList= new List<Task>(new[] {