Page 1 of 1
Forced closing of all windows from the outside
Posted: Mon Mar 03, 2014 7:37 am
by Eugene Lutsenko
I had such a problem. In the system of many modes , many of them use the same database. I open the database , and if the window is exclusive one mode is not closed , then launch another that accesses the same database , naturally causes a programming error because some base to which he refers , busy with other regime.
I would like to be able to forcibly close a previously opened windows and database before you run the new regime , all without even knowing what it was. Very similar to how you can close the application from the Application Manager , the software only. Otherwise you have to manually close the previous window before opening a new one. It's uncomfortable , and not all users are doing.
Re: Forced closing of all windows from the outside
Posted: Mon Mar 03, 2014 11:24 am
by rdonnay
You do this only if the other applications that open the databases are your own applications where you have the source code.
You need to run a thread in all the applications that look for the existence of a file.
If the file exists, the programs all shut down.
Why are you using databases in EXCLUSIVE mode?
You would not be having this problem if they were opened in SHARED mode.
Re: Forced closing of all windows from the outside
Posted: Mon Mar 03, 2014 8:33 pm
by Eugene Lutsenko
Hi, Roger!
I tell you about the students and show photo on the cover on the background clipper "old sea dog".
I do not open the database in SHARED, since it requires more sophisticated programming (lock, unlock, expectations and the like), but in fact most multi-user access is not required. Just need to close the previously opened window opens when new, but doing it programmatically it when opening a new window, and not very close them manually.
Re: Forced closing of all windows from the outside
Posted: Tue Mar 04, 2014 8:18 am
by Cliff Wiernik
You can get the same easy of use without opening exclusively. In your open code, just do a file lock. Then you do not need to be concerned about locking, unlocking, etc. Just don't do any locking.
Cliff
Re: Forced closing of all windows from the outside
Posted: Tue Mar 04, 2014 10:53 am
by Eugene Lutsenko
Hi, Cliff! How many years - how many winters! Nice to hear from you. Thank you for responding. And could not bring the piece of code? Look what I heaped:
http://lc.kubagro.ru/Dima/a.doc Look yourself in the text search
Re: Forced closing of all windows from the outside
Posted: Tue Mar 04, 2014 8:08 pm
by Cliff Wiernik
Record number of below zero days in my area this year. Had seen the acknowledgment previously. Thanks.
Re: Forced closing of all windows from the outside
Posted: Wed Mar 05, 2014 3:09 am
by Tom
Eugene -
you may take a look at the "TIMEOUT"-option of DCREAD GUI:
Code: Select all
DCREAD GUI ... TIMEOUT {n,{||AnyFunction()}}
This will evaluate "AnyFunction" every n seconds. If "AnyFunction" returns .F., nothing happens. If it returns .T., the dialog is closed - as long as nothing else happened within the "n" seconds. So, "AnyFunction" could check a Get-Set-function "ShutDown" like this:
Code: Select all
FUNCTION AnyFunction()
IF ShutDown()
RETURN .T.
ENDIF
RETURN .F.
FUNCTION ShutDown(lShutDown)
STATIC lShutDownCreated := .F.
IF PCount()=1
lShutDownCreated := lShutDown
ENDIF
RETURN lShutDownCreated
If you now want to close all dialogs using this, call "ShutDown(.T.)". This should close all those dialogs. Just add the statement "TIMEOUT {n,{||AnyFunction()}}" to all DCREAD GUIs, which is no work with search&replace.
Re: Forced closing of all windows from the outside
Posted: Wed Mar 05, 2014 12:45 pm
by Eugene Lutsenko
Thank you, Tom! This is an interesting and useful feature!
Re: Forced closing of all windows from the outside
Posted: Wed Mar 05, 2014 1:37 pm
by Tom
My code is a little redundantly. Forget "AnyFunction" and use "ShutDown" directly instead.