在我的TFS2012构建工作流程中,我有一个Parallel活动,在一些分支中我尝试了最终的活动。如果一个分支失败(例如,使用CodeAnalysis进行编译发现CodeAnalysis错误),则其他分支将被取消。但是,如果分支位于具有finally
块的try块内,则finally块将运行,如果超过30秒,则取消将失败:
BuildWarning: The workflow instance accepted a stop request but did not complete within 00:00:29.9922015. This may indicate an AsyncCodeActivity is active that does not support cancellation.
我想避免这样的消息,所以:
try-finally
内引发异常时,我可以以某种方式进行最终运行的try
活动吗?if
块中添加finally
工作流已被取消,而不是做很长时间。我怎么知道工作流程已被取消? 编辑:此模式甚至出现在TFS2012附带的DefaultTemplate.11.1.xaml中 - CopyDirectory可能需要很长时间,但它位于TryCatch.Finally
内:
<TryCatch DisplayName="Try Compile, Test, and Associate Changesets and Work Items">
<TryCatch.Finally>
<Sequence DisplayName="Revert Workspace and Copy Files to Drop Location">
<mtbwa:InvokeForReason DisplayName="Revert Workspace for Shelveset Builds" Reason="CheckInShelveset, ValidateShelveset">
<mtbwa:RevertWorkspace DisplayName="Revert Workspace" Workspace="[Workspace]" />
</mtbwa:InvokeForReason>
<If Condition="[Not String.IsNullOrEmpty(DropLocation)]" DisplayName="If DropLocation is Set">
<If.Then>
<mtbwa:CopyDirectory DisplayName="Drop Files to Drop Location" Source="[BinariesDirectory]" Destination="[DropLocation]" />
</If.Then>
</If>
</Sequence>
</TryCatch.Finally>
<TryCatch.Try>
(...)
</TryCatch.Try>
</TryCatch>