Detect from matlab whether other programs are not responding [SOLVED]

1 次查看(过去 30 天)
I'd like to share something I couldn't find a straightforward answer to by googling.
I use a program outside matlab to make some calculations. I write the code for the program in matlab, load it outside matlab, and then interact with the program's GUI for it to run. finally I import the calculated outputs. Loading the files in the program commonly puts it in "not responding" mode for few seconds and I'd like to interact with the GUI when it comes back to life.
To detect wether it's not responding I use:
[~,result] = system('tasklist /fi "status eq not responding" /fi "Imagename eq phreeqci.exe" /nh');
where "phreeqci.exe" is my program (as presented in Tasklist or Task Manager). "result" will give a line with details about the program if it is in fact non-responsive and the warning:
INFO: No tasks are running which match the specified criteria.
if it is responsive.
waiting for it to respond looks like this:
status=0;
while status==0
[~,result] = system('tasklist /fi "status eq not responding" /fi "Imagename eq phreeqci.exe" /nh');
status=strcmp(result,[['INFO: No tasks are running which match the specified criteria.' char(10) '']]);
end
fprintf('Responsive!\n')
I was not familiar with using the command line and this link helped me: https://technet.microsoft.com/en-us/library/bb491010.aspx
Hope this would help someone out there.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by