Forced closing function
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Forced closing function
Is there a way to Alaska to forcibly close a specific function previously running with the command from another function?
Re: Forced closing function
Code: Select all
Function Function1()
DO WHILE RunThisFunc()
* Code
ENDDO
RETURN NIL
FUNCTION RunThisFunc(lSetRun)
STATIC RunIt := .T.
IF PCount()=1
RunIt := lSetRun
ENDIF
RETURN RunIt
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Forced closing function
Thank you, Tom! That's understandable. But I had something else in mind. Let's say somewhere in the program I ran a function whose name he brought in when you start the database, and at the completion of the function is the name of the database is deleted. And elsewhere in the program looked at the database, I saw that at the moment the function is executed with the same name, and forcibly interrupted her performance, and then removed her name from the database. In this case the function of demand itself can have any form, for example it may be the screen form with the dialogue process and generally anything. In other words the software to do what we can do manually in Task Manager when forcibly stop the program, but the program and function. Thus it is desirable to open all database function interrupted closed at the termination of its operation.
Re: Forced closing function
you just can "kill a Task" ... but it does not say what will happens with your Data !Eugene Lutsenko wrote:In other words the software to do what we can do manually in Task Manager when forcibly stop the program, but the program and function.
CLOSE ALL will close all Database in one WorkSpaceArea.Eugene Lutsenko wrote:Thus it is desirable to open all database function interrupted closed at the termination of its operation.
If you use Threads that you have care of different WorkspaceArea.
Code: Select all
PROCEDURE AppExit()
LOCAL bErrorHandler :=ErrorBlock( {|e| Break(e)} )
LOCAL aWS, i
/*
* Absichern der shutdown-sequence vor rekursiven Fehlern
* in DbCommit() udgl.
*/
aWS := WorkSpaceList()
FOR i:= 1 TO len(aWS)
BEGIN SEQUENCE
/*
* Erzwinge das erfolgreiche Beenden aller
* anstehenden Record updates im aktuellen
* Workspace.
*/
(aWS[i])->(DbCommit())
(aWS[i])->(DbCloseArea())
RECOVER
(aWS[i])->(DbRRollback())
(aWS[i])->(DbCloseArea())
ENDSEQUENCE
NEXT
ErrorBlock( bErrorHandler )
RETURN
greetings by OHR
Jimmy
Jimmy
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Forced closing function
And as I can "kill task", ie close the previously executed function from another function. With these all will be fine, as I can before closing all databases
Re: Forced closing function
i say it again : if you do not "close" your Database before "kill Task" your Data will be corrupt !!!Eugene Lutsenko wrote:And as I can "kill task", ie close the previously executed function from another function. With these all will be fine, as I can before closing all databases
to "kill a Task" you have to find its (Windows) Handle.
if you have the Title of a Window you can use FindWindowsA() API Function this Way
Code: Select all
Function KillWindow(cTitle)
LOCAL hWndDlg
hWndDlg := DllCall( "User32.dll", DLL_STDCALL, "FindWindowA", 0, cTitle )
IF !( hWndDlg == 0 )
SendMessageA( hWndDlg, WM_QUIT, 0, 0 )
ENDIF
Code: Select all
nEvent := AppEvent ( @mp1, @mp2, @oXbp )
DO CASE
CASE nEvent == xbeP_Quit
QUIT // AppQuit()
CASE ...
OTHERWISE
oXbp:HandleEvent ( nEvent, mp1, mp2 )
ENDCASE
greetings by OHR
Jimmy
Jimmy
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Forced closing function
I'll try to make the system mode, which closes all open windows