Guest User

Untitled

a guest
Jul 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. [status, result] = system('EX.exe');
  2.  
  3. [status, result] = system('start EX.exe');
  4.  
  5. setappdata(0, 'running', 1);
  6.  
  7. tim = timer(...
  8. 'StartDelay', 2, ...
  9. 'TimerFcn', 'while getappdata(0, ''running''), fprintf(''timer running ...n''); pause(1); end' ...
  10. );
  11.  
  12. fprintf('Starting timer.n');
  13. start(tim);
  14.  
  15. fprintf('Calling external program ...n');
  16. [s,r] = system('EX.exe');
  17. fprintf('External program returned %d.n', s); % <-- This is never reached.
  18.  
  19. setappdata(0, 'running', 0);
  20.  
  21. fprintf('Stopping timer.n');
  22. stop(tim);
  23. delete(tim);
  24.  
  25. >> runtime = java.lang.Runtime.getRuntime();
  26. >> process = runtime.exec('program arg1 arg2');
  27. >> ...
  28. >>
  29. >> % when you want to collect results.
  30. >> process.waitFor(); % block until program returns.
  31. >> process.exitValue(); % fetch process return code.
  32. >>
  33. >> % or, if you need to abandon the work,
  34. >> process.destroy(); % violently kill process
Add Comment
Please, Sign In to add comment