How can I create an input dilaog window which is not block the running of the main window process?
2 次查看(过去 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 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!