最后,块在取消try块时运行

时间:2013-09-09 13:10:04

标签: workflow tfs2012 tfsbuild cancellation try-finally

在我的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.

我想避免这样的消息,所以:

  1. try-finally内引发异常时,我可以以某种方式进行最终运行的try活动吗?
  2. 如果没有,我想在if块中添加finally工作流已被取消,而不是做很长时间。我怎么知道工作流程已被取消?
  3. 编辑:此模式甚至出现在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>
    

0 个答案:

没有答案