I will preface that I have not got to any tutorials on tasks and as such am flying blind.
Through google-fu I hacked together something that uploads the file and updates the progress bar on the form. THis all works without issue.

I want to be able to cancel the task via Button_Cancel_Click. I click it and nothing happens.
I’ve removed other bits of code in-between not relating to the task at hand.
Any help/advice/hints/beer on how to make this work is greatly appreciated.
TIA
https://pastebin.com/HrVEzQap

A cancellation token does not know when to stop the task safely automatically. You need to pass it to your upload function and have it check for cancellation. I’ll write a bit more tomorrow as I’m checking this on my phone, but I would suggest looking into how cancellation tokens work. 😉
I was assuming that the Task.Run was somehow aware of the token’s state.
I’ll hit the books again.

source