I cant remember if windows forms has the OnInitDialog(), if so override that and for the closing of the dialog you can override OnClose(). when you overwrite onclose make sure you call DestroyWindow() from the parent class.
use thread for your application. you can run your algorithm on thread. then only u can able to click the stop button. there is lot of articles in this site for thread. go thru that. have a nice day! Murali.M