Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7733079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:53:45+00:00 2026-06-01T06:53:45+00:00

I have a custom MSBuild task for xUnit.net. When the task is running, if

  • 0

I have a custom MSBuild task for xUnit.net. When the task is running, if I hit Ctrl+C, it ‘tries’ to cancel the task, but of course it fails (since my task doesn’t support cancelation). No amount of MSDN doc searchs or Google-fu have landed on a solution. Since I can’t find an obvious interface to implement, I’m guessing maybe cancelation is supported by way of some convention.

Has anybody done this before, and knows what’s required to get cancelation to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:53:46+00:00Added an answer on June 1, 2026 at 6:53 am

    Your task needs to implement ICancelableTask. It’s a very simple interface added in 4.0.

    Basically you just add a Cancel() method. It must be ready to be called on a different thread, at any time, and return promptly. Your task must then return from Execute promptly. Typically you’d set a boolean flag inside Cancel(). Then inside your task you’d typically have a loop processing each input in turn — for example, copying one file after another — and in each iteration, check the flag; if it’s true, break out. It doesn’t matter whether you return true or false from Execute in this context.

    If you’re deriving from ToolTask — if your task spawns a tool, it’s very strongly recommended that you do this, as it saves a great deal of code, handles async logging, and other things — then it already handles Cancel automatically. When Cancel happens, it kills the tool it spawned and all its children. The C++ team’s tasks in some cases override this default behavior, so that their compiler/linker has a few seconds to clean up their half-written outputs before returning.

    (Trivia: when I first implemented this in MSBuild, I accidentally made VS bluescreen the box occasionally. This nearly shipped in VS10 beta but was discovered just in time. The bluescreen was because the logic for figuring out the process tree was wrong, and would sometimes kill a system process. Oops.)

    Dan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom MSBuild task that peeks inside an assembly to get some
I have a custom MSBuild task, which processes a set of files and returns
I have written a custom MSBuild task, call it TaskA, that parses a file
As part of some build automation of running xUnit.net tests with MSBuild , I'm
I'm trying to switch our build from CruiseControl.NET running a custom .msbuild file to
I was looking around the net for a NUnit custom MSBuild task that would
I have a custom MsBuild task that sends an email (does some special stuff
I have a very odd issue, where I've created a custom MSBuild task that
I've written a custom MSBuild task to generate model code from MSSQL stored procedures.
I have a msbuild script with custom logic to deploy my service to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.