Page 1 of 1

Application remains in system

Posted: Fri May 03, 2013 12:41 am
by skiman
Hi,

The following sometimes happens:
- In my application I'm using a lot of threads.
- Sometimes a thread is getting a problem, in my case I can simulate it by de-connecting the network plug. The thread is hanging because of the timeout on the network.
- I close the application with the normal procedure.

When I check the system afterwards, my application remains in the system processes. It looks as that blocked thread stays somewhere in memory.

Can I check all the threads when closing my application, and can I force them to close/destroy?

Re: Application remains in system

Posted: Sun May 05, 2013 12:58 pm
by rdonnay
Chris -

If a thread is still responding to events you can always push an event to it.
I use the below function to close all windows in all threads.

Code: Select all

FUNCTION CloseAllWindows()

LOCAL i, aChildList, nSeconds := Seconds()

DO WHILE !Empty( aChildList := Set_MainWindow():drawingArea:childList())

  FOR i := 1 TO Len(aChildList)
    IF !aChildList[i]:isDerivedFrom('XbpDialog')
      aChildList[i]:destroy()
    ELSE
      PostAppEvent(xbeP_Close,,,aChildList[i])
    ENDIF
    Sleep(10)
  NEXT

  IF Seconds() - nSeconds > 10
    EXIT
  ENDIF

ENDDO

Sleep(10)

RETURN nil
In eXpress++ build 259, I have improved the DC_InspectThreads() function to be able to display the stack and all work area information for all threads by using a similar technique.

Re: Application remains in system

Posted: Mon May 06, 2013 1:27 am
by skiman
Hi Roger,

Set_MainWindow() seems to be a function which is not standard eXpress++? I'm getting an error when I try to compile your code: 'Unresolved external symbol'.

Re: Application remains in system

Posted: Mon May 06, 2013 7:05 am
by rdonnay
This was just a get-set function that pointed to the main window dialog object.

You can change it to AppDeskTop():childList()[1].
That should also point to the main window.