This won't be handle able using ASP.NET because ASP.NET doesn't work with such task.
To cancel the event handler you can here use the C#
Thread
. Which will execute if the button2 is not clicked, and will stop if you click on the button2.
C# threads are very helpfull if you're working with data that depends on the state of some other process. This way you can handle the UI seperately and the business logic will be handled seperately.
So the short answer will be, to create a class inside the App_Code folder and then use the Thread in that file, and create the function to trigger the Thread and if the second button is clicked stop the thread.
http://msdn.microsoft.com/en-us/library/system.threading.thread(v=vs.110).aspx[
^]