Forced closing function

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Forced closing function

#1 Post by Eugene Lutsenko »

Is there a way to Alaska to forcibly close a specific function previously running with the command from another function?

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Forced closing function

#2 Post by Tom »

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
Any other func/proc can terminate Function1 now by calling RunThisFunc(.F.).
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
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

#3 Post by Eugene Lutsenko »

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.

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Forced closing function

#4 Post by Auge_Ohr »

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.
you just can "kill a Task" ... but it does not say what will happens with your Data !
Eugene Lutsenko wrote:Thus it is desirable to open all database function interrupted closed at the termination of its operation.
CLOSE ALL will close all Database in one WorkSpaceArea.
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

User avatar
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

#5 Post by Eugene Lutsenko »

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

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Forced closing function

#6 Post by Auge_Ohr »

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
i say it again : if you do not "close" your Database before "kill Task" your Data will be corrupt !!!

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
this work with Xbase++ Application if you have

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

User avatar
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

#7 Post by Eugene Lutsenko »

I'll try to make the system mode, which closes all open windows

Post Reply