How to handle error in callback function triggered by an event?
36 次查看(过去 30 天)
显示 更早的评论
Hi All,
I have an instance of a class I created that can trigger events. I have other classes that set listeners on this object and execute some stuff in a callback function. The callback function may do some error checking and use the error() function to raise an exception if there is an issue. What I was hoping for is that when this happens, that MATLAB would cease executing any remaining listeners as well as the function that triggered the event.
However, from the MATLAB documentation,
Callback function execution continues until the function completes. If an error occurs in a callback function, execution stops and control returns to the calling function. Then any remaining listener callback functions execute.
So what I can do to get around this? Should I be using something other than an event in this case?
Thanks.
0 个评论
采纳的回答
Walter Roberson
2014-4-2
Notice on the same page http://www.mathworks.com/help/matlab/matlab_oop/events-and-listeners--syntax-and-techniques.html
The order in which listeners callback functions execute after the firing of an event is undefined.
Which listeners are "remaining" is thus subject to change -- between releases at the very least, and plausibly the listener order could vary between events. The documentation speaks of the event being "broadcast" to all of the listeners; MATLAB has never defined the order in which competing interrupts (at the same level) are executed.
If you had the handles of the other listeners, you could set them disabled -- though it is not clear that would affect ones that had already been notified.
There are no documented tools to query or change the listener order, so abstractly at least, you are not intended to know or change the order.
4 个评论
vaka sindhu
2014-4-2
sir i am new to this matlab i want to satisfy the equation (512*512*log2(B))/>=520000 by keeping what value of B this equation will be satisfied answer is 16 .. i want how to do code for this equation in matlab by taking B values automatically to satisfy this equation
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!