我不知道我是不是这样做,或者我是否必须以不同的方式处理内置的gradle任务,但我有一个我定义的测试任务
task testNGTests(type: Test) {
useTestNG()
}
Run Code Online (Sandbox Code Playgroud)
我试图在这样的doFirst闭包中使用它
task taskA {
doFirst {
testNGTests.execute()
}
}
Run Code Online (Sandbox Code Playgroud)
但由于某种原因它不起作用,我也试过了
testNGTests.executeTests()
Run Code Online (Sandbox Code Playgroud)
但那也不起作用.我是否有一种特殊的方式来处理内置的测试任务?
我使用的是gradle版本0.9.2
在我的应用程序中的所有服务调用实现为tasks.When永远的任务发生故障,我需要一个对话框,向用户呈现failed.If用户选择重试程序应该重试任务重试最后一次操作,否则记录异常后,程序的执行应该继续.任何人都对如何实现这个功能有了很高的想法?
在连续链中传播异常的正确方法是什么?
t.ContinueWith(t2 =>
{
if(t2.Exception != null)
throw t2.Exception;
/* Other async code. */
})
.ContinueWith(/*...*/);
t.ContinueWith(t2 =>
{
if(t2.IsFaulted)
throw t2.Exception;
/* Other async code. */
})
.ContinueWith(/*...*/);
t.ContinueWith(t2 =>
{
if(t2.Exception != null)
return t2;
/* Other async code. */
})
.ContinueWith(/*...*/);
t.ContinueWith(t2 =>
{
if(t2.IsFaulted)
return t2;
/* Other async code. */
})
.ContinueWith(/*...*/);
t.ContinueWith(t2 =>
{
t2.Wait();
/* Other async code. */
})
.ContinueWith(/*...*/);
t.ContinueWith(t2 =>
{
/* Other async code. */
}, TaskContinuationOptions.NotOnFaulted) // Don't …Run Code Online (Sandbox Code Playgroud) 使用JavaFX和Threads时遇到问题.基本上我有两个选择:使用Tasks或Platform.runLater.据我所知,Platform.runLater应该用于简单/简短的任务,以及Task较长的任务.但是,我不能使用它们中的任何一个.
当我打电话时Thread,它必须在任务中间弹出验证码对话框.在使用时Task,它忽略了我显示新对话框的请求......它不允许我创建一个新阶段.
另一方面,当我使用时Platform.runLater,它让我显示一个对话框,但是,程序的主窗口冻结,直到显示弹出对话框.
我需要任何解决方案.如果有人知道如何处理这个或有一些类似的经验,并找到了解决方案,我期待着您的回复!
对于org-mode中的循环或重复任务,在此任务中,如果有多个复选框并且所有这些复选框都标记为勾选,则在将常规任务屏蔽为DONE后,下一个循环周期的复选框仍显示为勾选并且应该未被攻击.例如:
- TODO Cyclic月度住宿[0/5]预定:<2013-11-30周六+ 1米>
- []付桑拿
- []支付电费
- []支付租金
- []付费上网
- []付工会
一旦我勾选所有这些并完成它,我就能看到:
- WIP循环月度住宅[5/5]预定:<2014-01-30周四+ 1m>
- 从"WIP"状态"完成"[2013-11-06 Wednesday 20:49]:PROPERTIES :: LAST_REPEAT:[2013-11-06 Wed 20:49]:END:
- [X]支付桑拿<---这应该是未经批准的
- [X]支付电费< - 这应该是未经批准的
- [X]支付租金< - 这应该是未经批准的
- [X]支付互联网< - 这应该是未经批准的
- [X]支付工会< - 这应该是未经批准的
测试版本:
Emacs版本:*2013-08-30关于apocalipsis的GNU Emacs 24.3.1(x86_64-unknown-linux-gnu,X工具包,Xaw3d滚动条)*
组织模式版本:*组织模式版本7.9.3f(release_7.9.3f-17-g7524ef @ /usr/local/share/emacs/24.3/lisp/org/)*
(add-to-list'load-path(expand-file-name"〜/ path_to_file_org-checklist.el /"))
(要求'组织清单)
注意:如果您没有该文件,可以从此处下载
:属性:
:RESET_CHECK_BOXES:t
:结束:
只需关闭任务,C-c C-t您就会看到未选中的复选框.
我正在处理一个gulp文件,其中包含我的站点的前端和后端的任务.
例如,下面的任务将我的脚本连接到app.js:
gulp.task 'frontend:scripts', ->
gulp.src frontendPath(scriptsFolder, scriptsPattern)
.pipe sourcemaps.init()
.pipe coffee()
.pipe concat 'app.js'
.pipe sourcemaps.write('.')
.pipe gulp.dest frontendPath(tempFolder, scriptsFolder)
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我已经创建了一个帮助程序来提供正确的前端路径:
frontendPath = (dirs...) -> path.join.apply null, ['frontend'].concat(dirs)
Run Code Online (Sandbox Code Playgroud)
但我必须非常小心,我的任务的所有步骤(尤其是.src和.dest)都在前端文件夹中执行.
我知道您可以使用该{ cwd: 'frontend' }选项更改.src和.dest的工作目录.但有没有办法改变任务的整个工作目录?
我正在开发一个使用Spring和Hibernate的网站(该网站是关于股票交易).
每天凌晨12点左右,我需要取消所有订单.目前我的解决方案是使用每小时运行的计划任务:
<task:scheduled ref="ordersController" method="timeoutCancelAllOrders" fixed-delay="60*60*1000" />
Run Code Online (Sandbox Code Playgroud)
然后在方法timeoutCancelAllOrders中,我得到当前时间并检查,如果它是在晚上11点到12点之间然后执行任务
我看到它的方式,任务计划在我启动服务器时启动(我在Eclipse中使用Tomcat),但是当我在在线托管上部署它时(我正在使用Openshift),我不知道什么时候是启动时间任务时间表.
1:如何更自动地做到这一点?有什么像myTask.startAt(12AM)吗?
2:我住在越南,但服务器(Openshift)位于美国,所以这里是我的检查方式:
Date currentTime = new Date();
DateFormat vnTime = new SimpleDateFormat("hh:mm:ss MM/dd/yyyy ");
vnTime.setTimeZone(TimeZone.getTimeZone("Asia/Ho_Chi_Minh"));
String vietnamCurrentTime = vnTime.format(currentTime);
String currentHourInVietnam = vietnamCurrentTime.substring(0, 2);
System.out.println(currentHourInVietnam);
if(currentHourInVietnam.equals("00")){
// DO MY TASK HERE
}
Run Code Online (Sandbox Code Playgroud)
这看起来很愚蠢.我该如何改进我的代码?
使用NSubstitute,如何模拟返回任务的方法中抛出的异常?
假设我们的方法签名看起来像这样:
Task<List<object>> GetAllAsync();
Run Code Online (Sandbox Code Playgroud)
以下是NSubstitute文档如何模拟抛出非void返回类型的异常.但这不编译:(
myService.GetAllAsync().Returns(x => { throw new Exception(); });
Run Code Online (Sandbox Code Playgroud)
那你怎么做到这一点?
我想每秒执行一些代码.我现在使用的代码是:
Task.Run((作用)ExecuteSomething);
并ExecuteSomething()定义如下:
private void ExecuteSomething()
{
Task.Delay(1000).ContinueWith(
t =>
{
//Do something.
ExecuteSomething();
});
}
Run Code Online (Sandbox Code Playgroud)
这个方法会阻塞一个线程吗?或者我应该Timer在C#中使用class?似乎Timer还专门用于执行(?)
我有两个任务。我用 Task.WhenAll 运行它们。如果其中一个抛出异常会发生什么?另一个会完成吗?