Should a cancel button ask for confirmation?

user-interface, winforms

Solution

If canceling the action will destroy data or a device, yes. For instance, canceling in the middle of upgrading the firmware of some device.

If the action being performed takes a long time and an accidental cancelation will require starting over, yes.

For instance, I don't find the pop-up here on StackOverflow annoying when I decide to close a tab rather than making an edit I started on one of my questions.

Problem

If a user clicks a cancel button should it pop up a dialogue asking for confirmation? If so, should this be all the time, or only when there are unsaved changes on a form?

Original source