I have an application for which I developed a progressbar figure with the help of a function I wrote progressbar_auto. I wanted a cancel button on the progressbar which I created using uicontrol. The callback function is executed ONLY when I put a breakpoint after the uicontrol statement and then click on the button Cancel that I created. I thought MATLAB would by default keep checking the push button to see if it has been clicked. I think the issue is that MATLAB does not check for the button until it has completed the remaining processes, and in this case the entire process may even take an hour which is why I kept a progressbar. I even tried creating the uicontrol push button in my main code instead of the function progressbar_auto, that still does not work. It seems that MATLAB recognizes the clicking of the button only if I click on Cancel right after it created a uicontrol for which I put a breakpoint, this is obviously not the way it should work. What should I do? Can anyone give me some advice on how to include a responsive cancel button on the progressbar for a long process?