The interesting error I occur when I push the two button at the same time.

In my gui code,there is a pushbutton1_callback function and a pushbutton2_callback function with a for loop and waitbar.
If I push the button2,the pushbutton2_callback will do the loop.Before the loop ends,I also push the button1. Then the pushbutton1_callback function will begin and pushbutton2_callback is paused.When the pushbutton1_callback ends,the pushbutton2_callback begins where it is paused.Also it gives out the error message 'Couldn't find waitbar handles'.
However,if I add the code 'pause(2)' at the end of pushbutton1_callback.The error message would not appear.It's very interesting. Do you know the answer?

3 件のコメント

Jing
Jing 2013 年 3 月 7 日
Is it the same waitbar in those two callback? And did you close it in pushbutton1_callback?
Walter Roberson
Walter Roberson 2013 年 3 月 7 日
waitbar() has calls to wait for events, so other pushbuttons are allowed to interrupt the process.
QiQin Zhan
QiQin Zhan 2013 年 3 月 7 日
@Jing: The waitbar and loop are in the pushbutton2_callback.I'm sure the waitbar wasn't cloesed because if I add the code 'pause(2)' at the end of pushbutton1_callback,there would be no error message.
@ Walter Roberson: If I pause 2 seconds or longer,the code is runnnig correctly.What's more,if there are more data to proceed in pushbutton2_callback.The time to pause should be even longer,or the error message will appear again.How can I solve it?

サインインしてコメントする。

回答 (1 件)

QiQin Zhan
QiQin Zhan 2013 年 3 月 7 日

0 投票

I think I've known what's wrong.The code in pushbutton1_callback opens a msgbox. If I comment the msgbox,there would be no error message.If I set a breakpoint where the msgbox generate,and close the msgbox before the pushbutton2_callback begins where it is paused.There would also be no error.Why is it so strange?

4 件のコメント

Walter Roberson
Walter Roberson 2013 年 3 月 7 日
Which form of waitbar() are you using? Are you passing in the handle to it or are you forcing it to search for the current handle?
QiQin Zhan
QiQin Zhan 2013 年 3 月 7 日
編集済み: QiQin Zhan 2013 年 3 月 7 日
I embed it in the GUI and it is used to show the process of loop.
Walter Roberson
Walter Roberson 2013 年 3 月 7 日
Please show your waitbar() command.
QiQin Zhan
QiQin Zhan 2013 年 3 月 7 日
s=sprintf('Simulation in process:%d',floor(i/n*100));
waitbar(i / n, gcf, [s '%']);

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

タグ

質問済み:

2013 年 3 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by