How to handle error in callback function triggered by an event?

35 ビュー (過去 30 日間)
Leor Greenberger
Leor Greenberger 2014 年 4 月 1 日
コメント済み: vaka sindhu 2014 年 4 月 2 日
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.

採用された回答

Walter Roberson
Walter Roberson 2014 年 4 月 2 日
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 件のコメント
Leor Greenberger
Leor Greenberger 2014 年 4 月 2 日
I was thinking that might be the only way. Thanks for your help.
vaka sindhu
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 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by