How to make a script wait for a background process to complete before continuing
15 ビュー (過去 30 日間)
古いコメントを表示
Hey guys, I have a Matlab GUI that requires output from a separate piece of image processing software (ImageJ).
The GUI asks for a file - the file is an LSM file, a specialised image file for use with Zeiss fluorescence imaging microscopes - and uses the system command to tell ImageJ to execute. This takes a few seconds, and currently i'm using a pause command in the code to loop until the last output file from ImageJ is created before commencing.
[pathstr, name, ext] = fileparts(LSMfile);
opt = '-batch';
ProcessLSM = sprintf('%s%s%s%s%s','imagej ',opt,' LSMtoTiff1.ijm "',LSMfile,'"');
system(ProcessLSM);
readNDD2 = 'C:\Temp\NDD2.tif';
readNDD3 = 'C:\Temp\NDD3.tif';
tStamps = 'C:\Temp\Timestamps.txt';
pause on
while exist(tStamps,'file') == 0;
pause(0.1);
end
pause off
While this works, it seems quite cumbersome. Is there any way of having the GUI wait until ImageJ.exe closes in the background before then commencing, instead of using a pause function?
Thanks, Allen
0 件のコメント
回答 (2 件)
msand65
2017 年 8 月 14 日
Here is what I did for a similar problem: I have a script calling a GUI. The GUI would open and then close without running. So, I assigned a value in the GUI (value_out), had the GUI output to the calling script (function value_out = GUI), and then I put a "waitfor(value_out)" in the calling script after the call to the GUI. There may be some better way to do this (and this may be exactly what Ryan G was implying) but now the script runs and waits for the GUI to be closed before continuing.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!