How can I create an input dilaog window which is not block the running of the main window process?
7 ビュー (過去 30 日間)
古いコメントを表示
I created a data acquisition and processing program. It works fine. I would like to be able to change parameters simultaniously, which would effects the data process. I can do it but all solution I found interrupt/block the running processes what I would really like to avoid. Is there any solution?
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 10 月 27 日
If you need to change the data acquisition parameters, then probably you will need an interruption in the data acquisition in order to have a chance for the new parameters to go into effect. This isn't what you asked about, but it has to be taken into account.
If the parameters are used to change what you calculate with the data you acquire (and no change to how the data is acquired) then if you might be able to do what you want.
An input dialog can exist that does not block the running program. You create a figure for the dialog, and populate controls on the dialog, and set callback routines -- and then leave it sitting there and return to what you were doing.
When the user interacts with the dialog in ways that do not require callback routines to be fired, such as by typing into an edit box without pressing enter, then those interactions are taken care of automatically, possibly by a different java thread. On a single processor system, that java thread would inherently need to interrupt the running program very briefly -- but the operating system is interrupting the running program constantly to maintain the various other bits of the system, so this is nothing special. It just happens and MATLAB continues exactly where it was.
When the user interacts with the dialog in ways that do require graphics callback routines to be fired, such as by selecting an element in a listbox or pressing enter in an edit box, then that MATLAB-level interrupt routine will not be serviced until the program gives it permission to serve the routine, which can happen by the program selecting or creating a figure, or by pause() or by drawnow() or by a small number of other means. If you are running a compute-intensive routine, especially one that uses internal libraries such as LAPACK, then it could be some time before there is any opportunity to service the interrupt routine, and if you write your code at the MATLAB level such that it does not invoke any of the small list of key routines, MATLAB will not allow the interrupt routine to run.
When there is eventually an opportunity for the interrupt routine to execute at the MATLAB level, the interrupt routine can change variables or state that the other routine is paying attention to. There is, though, no way for the interrupt routine to "notify" the executing routine that something has changed: the executing routine would need to know to periodically look at the variables or state and change its operations accordingly. For example,
for K = 1 : 1e7
keep_going = get(handles.ContinueRunning_radiobutton, 'Value');
if ~keep_going; break; end
.... continue with the calculation ...
end
参考
カテゴリ
Help Center および File Exchange で Dialog Boxes についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!