Check if the programm is running already

23 次查看(过去 30 天)
Hello.
I wrote a programm for the app designer which is running after pressing the start button. The program starts a session with the aquisition toolbox.The problem is, when I press the button afterwards again it gives me back an arror because of the session that has already started before. So I need a peace of code, wich will check if the session is already running.
Unfortanly I have no clu how I can do it. I was thinking abaout if-else: If true, dont start again, else run the program. Could anyone give me some hints how to do it?
Thx

回答(1 个)

Manish Annappa
Manish Annappa 2017-10-11
There is a property called 'IsRunning' on the session object that can be used to check if the current session is active.
Note: However, this will work only if you are not clearing the work space or deleting the previous session object before 'Start' button click.
Here are a couple of other ways to achieve it.
1) Have a Stop button that will call a callback function which releases the current session by calling 'release' on the session object. Refer to the below link for more information on the 'release' function.
So, everytime click the 'Start' button after clicking 'Stop' button.
2) Calling 'daqreset' before creating the session in 'Start' button handler will make sure that all the current sessions are released.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by