1
votes

We are using Restart function in an application to close the application and re-open the same when the application is left idle for the specified period of time. The fucntion works fine when we call the function from SDI application but when we call the function from MDI, the application closes off after couple of restarts.

In MDI frame, when the function is trigger is first time, the application restart works fine. When we leave the application for another idle time and the restart function is triggered again, the applicaiton just closes off. It does not crash or anything but just closes. Any idea on how to troubleshoot and solve the issue. Thanks.

1
What code do you have in your idle event? I don't even remember a "restart" function in PB but it's been a while. I've seen companies start the application with a batch file, and let the batch file look at return codes and restart if needed. Will try to help with more info. - Rich Bianco

1 Answers

1
votes

One approach is after the idle event triggers, open a new instance of the application then close self.

This simple example is not designed to function in the IDE.

[PB external function declaration]

FUNCTION int GetModuleFileNameA(&
       ulong hinstModule, &
       REF string lpszPath, &
       ulong cchPath) LIBRARY "kernel32" alias for "GetModuleFileNameA;ansi"

[in the application open event]

if commandline = "RESTARTED" then
    messagebox( "Welcome Back!", "Click to Continue" )
end if

idle(300) // Restart the application if there is no activity for 5 minutes

Open ( w_main )

[in application IDLE event]

string ls_ExePathFileName
unsignedlong lul_handle

ls_ExePathFileName = space(1024)

lul_handle = Handle(GetApplication())
GetModuleFilenameA(lul_handle, ls_ExePathFileName, 1024)
run( ls_ExePathFileName + " RESTARTED" )

HALT CLOSE