I've written a console application that basically fires one BackgroundWorker that supports ReportProgress and Cancel.
How can I make sure that before a window is closed (by pressing the close button or pressing ctrl+c) the cancel operation is triggered on my thread and the window only closes after the cancel is completed?