Sign in to follow this  
Followers 0
jawnah

GUI Lockup When Running As Service

3 posts in this topic

I've been working to get a GUI application that provides the status on a service as it starts functioning. I managed to work out all the issues I had with actually launching the process as a service and getting the GUI to appear. However, it appears as though, as a service, the GUI doesn't work properly. The GUI just seems to lock-up on me once the service is fully initialized. If you try to interact with it, it just says "Not Responding". I can't seem to determine why this locks up. If I take out the code to run this as a service, I don't have a problem with the process. Also, if I paint the screens PRIOR to calling the service initialization functions, they at least paint completely before locking-up.

Any assistance would be appreciated. I've posted my code below:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <UpdownConstants.au3>
#include <Array.au3>
#include <_Service.au3>
#NoTrayIcon

_Service_Init("POSSample2")

; Function to start the app

Func main()
    Local $splashGui, $splashMsg, $splashText, $posProcess, $posOut, $startupString, $splashStatus, $splashProgress, $posOut2, $posOut3
    Local $pubDirectoryBound, $startupSize, $startupCount, $tempLine, $tempLine2, $startupSteps, $arrayStartupSteps, $startupIncrement
    Local $readBuffer, $bufferArray, $startupTotal, $arrayPos
    
    Dim $arrayStartupSteps[1]
    
    _ArrayAdd($arrayStartupSteps, "Dispatcher.configureDispatcher(): local tech LogTechnician started.")
    _ArrayAdd($arrayStartupSteps, "Dispatcher.configureDispatcher(): local app APPLICATION started.")
    
    _ArrayDelete($arrayStartupSteps, 0)
    
    $splashGui = GUICreate("Splash Screen", 500, 300)
    $splashStatus = GUICtrlCreateLabel("POS Application Status", -1, 5, 500, 25, $SS_CENTER)
    $splashProgress = GUICtrlCreateProgress(5, 30, 495, 20)
    $splashText = GUICtrlCreateEdit("", -1, 50, 475, 250, $ES_MULTILINE + $ES_AUTOVSCROLL,$UDS_WRAP)
    
    GUISetState()
    GUICtrlSetData($splashText, "Starting application..." & @CRLF, 1)
    GUICtrlSetData($splashText, "There are " & String(UBound($arrayStartupSteps)) & " items in the startup array." & @CRLF, 1)
    $startupIncrement = 100 / UBound($arrayStartupSteps)
    $startupIncrement = Round($startupIncrement)
    GUICtrlSetData($splashText, "-- We will be using increments of " & String($startupIncrement) & " for status" & @CRLF, 1)
    GUICtrlSetData($splashText, "The length of CRLF is " & StringLen(@CRLF) & @CRLF, 1)
    
    ;$posProcess = Run("C:\someapp\someapp.bat", "C:\someapp",@SW_MINIMIZE,$STDOUT_CHILD + $STDERR_CHILD)
    Do
        $splashMsg = GUIGetMsg()
        ;$posOut = StdoutRead($posProcess)
        ;$readBuffer = $readBuffer & $posOut
        ;If Not StringInStr($posOut, @CRLF) Then
        ;   ContinueLoop
        ;Else
        ;   $bufferArray = StringSplit($readBuffer, @CRLF, 2)
        ;   If Not StringRight($readBuffer, 2) = @CRLF Then
        ;       $readBuffer = _ArrayPop($bufferArray)
        ;   Else
        ;       $readBuffer = ""
        ;   EndIf
        ;EndIf
        
        ;For $i In $bufferArray
        ;   If $i = "" Then
        ;       ContinueLoop
        ;   EndIf
        ;   GUICtrlSetData($splashText, "-- Received: " & $i & @CRLF, 1)
            ;$arrayPos = _ArraySearch($arrayStartupSteps, $i)
            ;If  $arrayPos > -1 Then
            ;   GUICtrlSetData($splashText, "-- Found startup string!" & @CRLF, 1)
            ;   $startupTotal = $startupTotal + $startupIncrement
            ;   If $startupTotal > 100 Then
            ;       $startupTotal = 100
            ;   EndIf
            ;   GUICtrlSetData($splashProgress, $startupTotal)
            ;   If $arrayPos = UBound($arrayStartupSteps) - 1 Then
            ;       GUICtrlSetData($splashText, "-- Found last startup item, application done!" & @CRLF, 1)
            ;   EndIf
            ;EndIf
        ;   GUISetState()
        ;Next
    Until $splashMsg = $GUI_EVENT_CLOSE
    Exit
EndFunc

Func someFunc($sArgs, $iArgs)
EndFunc

jawnah--Have a blessed day :)

Share this post


Link to post
Share on other sites



Does anyone have any ideas on this issue? I haven't been able to resolve it myself. Any assistance would be appreciated. Thanks!

I've been working to get a GUI application that provides the status on a service as it starts functioning. I managed to work out all the issues I had with actually launching the process as a service and getting the GUI to appear. However, it appears as though, as a service, the GUI doesn't work properly. The GUI just seems to lock-up on me once the service is fully initialized. If you try to interact with it, it just says "Not Responding". I can't seem to determine why this locks up. If I take out the code to run this as a service, I don't have a problem with the process. Also, if I paint the screens PRIOR to calling the service initialization functions, they at least paint completely before locking-up.

Any assistance would be appreciated. I've posted my code below:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <UpdownConstants.au3>
#include <Array.au3>
#include <_Service.au3>
#NoTrayIcon

_Service_Init("POSSample2")

; Function to start the app

Func main()
    Local $splashGui, $splashMsg, $splashText, $posProcess, $posOut, $startupString, $splashStatus, $splashProgress, $posOut2, $posOut3
    Local $pubDirectoryBound, $startupSize, $startupCount, $tempLine, $tempLine2, $startupSteps, $arrayStartupSteps, $startupIncrement
    Local $readBuffer, $bufferArray, $startupTotal, $arrayPos
    
    Dim $arrayStartupSteps[1]
    
    _ArrayAdd($arrayStartupSteps, "Dispatcher.configureDispatcher(): local tech LogTechnician started.")
    _ArrayAdd($arrayStartupSteps, "Dispatcher.configureDispatcher(): local app APPLICATION started.")
    
    _ArrayDelete($arrayStartupSteps, 0)
    
    $splashGui = GUICreate("Splash Screen", 500, 300)
    $splashStatus = GUICtrlCreateLabel("POS Application Status", -1, 5, 500, 25, $SS_CENTER)
    $splashProgress = GUICtrlCreateProgress(5, 30, 495, 20)
    $splashText = GUICtrlCreateEdit("", -1, 50, 475, 250, $ES_MULTILINE + $ES_AUTOVSCROLL,$UDS_WRAP)
    
    GUISetState()
    GUICtrlSetData($splashText, "Starting application..." & @CRLF, 1)
    GUICtrlSetData($splashText, "There are " & String(UBound($arrayStartupSteps)) & " items in the startup array." & @CRLF, 1)
    $startupIncrement = 100 / UBound($arrayStartupSteps)
    $startupIncrement = Round($startupIncrement)
    GUICtrlSetData($splashText, "-- We will be using increments of " & String($startupIncrement) & " for status" & @CRLF, 1)
    GUICtrlSetData($splashText, "The length of CRLF is " & StringLen(@CRLF) & @CRLF, 1)
    
    ;$posProcess = Run("C:\someapp\someapp.bat", "C:\someapp",@SW_MINIMIZE,$STDOUT_CHILD + $STDERR_CHILD)
    Do
        $splashMsg = GUIGetMsg()
        ;$posOut = StdoutRead($posProcess)
        ;$readBuffer = $readBuffer & $posOut
        ;If Not StringInStr($posOut, @CRLF) Then
        ;   ContinueLoop
        ;Else
        ;   $bufferArray = StringSplit($readBuffer, @CRLF, 2)
        ;   If Not StringRight($readBuffer, 2) = @CRLF Then
        ;       $readBuffer = _ArrayPop($bufferArray)
        ;   Else
        ;       $readBuffer = ""
        ;   EndIf
        ;EndIf
        
        ;For $i In $bufferArray
        ;   If $i = "" Then
        ;       ContinueLoop
        ;   EndIf
        ;   GUICtrlSetData($splashText, "-- Received: " & $i & @CRLF, 1)
            ;$arrayPos = _ArraySearch($arrayStartupSteps, $i)
            ;If  $arrayPos > -1 Then
            ;   GUICtrlSetData($splashText, "-- Found startup string!" & @CRLF, 1)
            ;   $startupTotal = $startupTotal + $startupIncrement
            ;   If $startupTotal > 100 Then
            ;       $startupTotal = 100
            ;   EndIf
            ;   GUICtrlSetData($splashProgress, $startupTotal)
            ;   If $arrayPos = UBound($arrayStartupSteps) - 1 Then
            ;       GUICtrlSetData($splashText, "-- Found last startup item, application done!" & @CRLF, 1)
            ;   EndIf
            ;EndIf
        ;   GUISetState()
        ;Next
    Until $splashMsg = $GUI_EVENT_CLOSE
    Exit
EndFunc

Func someFunc($sArgs, $iArgs)
EndFunc

jawnah--Have a blessed day :)

Share this post


Link to post
Share on other sites

Did you try enabling "Allow service to interact with desktop"?

I've been working to get a GUI application that provides the status on a service as it starts functioning. I managed to work out all the issues I had with actually launching the process as a service and getting the GUI to appear. However, it appears as though, as a service, the GUI doesn't work properly. The GUI just seems to lock-up on me once the service is fully initialized. If you try to interact with it, it just says "Not Responding". I can't seem to determine why this locks up. If I take out the code to run this as a service, I don't have a problem with the process. Also, if I paint the screens PRIOR to calling the service initialization functions, they at least paint completely before locking-up.

Any assistance would be appreciated. I've posted my code below:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <UpdownConstants.au3>
#include <Array.au3>
#include <_Service.au3>
#NoTrayIcon

_Service_Init("POSSample2")

; Function to start the app

Func main()
    Local $splashGui, $splashMsg, $splashText, $posProcess, $posOut, $startupString, $splashStatus, $splashProgress, $posOut2, $posOut3
    Local $pubDirectoryBound, $startupSize, $startupCount, $tempLine, $tempLine2, $startupSteps, $arrayStartupSteps, $startupIncrement
    Local $readBuffer, $bufferArray, $startupTotal, $arrayPos
    
    Dim $arrayStartupSteps[1]
    
    _ArrayAdd($arrayStartupSteps, "Dispatcher.configureDispatcher(): local tech LogTechnician started.")
    _ArrayAdd($arrayStartupSteps, "Dispatcher.configureDispatcher(): local app APPLICATION started.")
    
    _ArrayDelete($arrayStartupSteps, 0)
    
    $splashGui = GUICreate("Splash Screen", 500, 300)
    $splashStatus = GUICtrlCreateLabel("POS Application Status", -1, 5, 500, 25, $SS_CENTER)
    $splashProgress = GUICtrlCreateProgress(5, 30, 495, 20)
    $splashText = GUICtrlCreateEdit("", -1, 50, 475, 250, $ES_MULTILINE + $ES_AUTOVSCROLL,$UDS_WRAP)
    
    GUISetState()
    GUICtrlSetData($splashText, "Starting application..." & @CRLF, 1)
    GUICtrlSetData($splashText, "There are " & String(UBound($arrayStartupSteps)) & " items in the startup array." & @CRLF, 1)
    $startupIncrement = 100 / UBound($arrayStartupSteps)
    $startupIncrement = Round($startupIncrement)
    GUICtrlSetData($splashText, "-- We will be using increments of " & String($startupIncrement) & " for status" & @CRLF, 1)
    GUICtrlSetData($splashText, "The length of CRLF is " & StringLen(@CRLF) & @CRLF, 1)
    
    ;$posProcess = Run("C:\someapp\someapp.bat", "C:\someapp",@SW_MINIMIZE,$STDOUT_CHILD + $STDERR_CHILD)
    Do
        $splashMsg = GUIGetMsg()
        ;$posOut = StdoutRead($posProcess)
        ;$readBuffer = $readBuffer & $posOut
        ;If Not StringInStr($posOut, @CRLF) Then
        ;   ContinueLoop
        ;Else
        ;   $bufferArray = StringSplit($readBuffer, @CRLF, 2)
        ;   If Not StringRight($readBuffer, 2) = @CRLF Then
        ;       $readBuffer = _ArrayPop($bufferArray)
        ;   Else
        ;       $readBuffer = ""
        ;   EndIf
        ;EndIf
        
        ;For $i In $bufferArray
        ;   If $i = "" Then
        ;       ContinueLoop
        ;   EndIf
        ;   GUICtrlSetData($splashText, "-- Received: " & $i & @CRLF, 1)
            ;$arrayPos = _ArraySearch($arrayStartupSteps, $i)
            ;If  $arrayPos > -1 Then
            ;   GUICtrlSetData($splashText, "-- Found startup string!" & @CRLF, 1)
            ;   $startupTotal = $startupTotal + $startupIncrement
            ;   If $startupTotal > 100 Then
            ;       $startupTotal = 100
            ;   EndIf
            ;   GUICtrlSetData($splashProgress, $startupTotal)
            ;   If $arrayPos = UBound($arrayStartupSteps) - 1 Then
            ;       GUICtrlSetData($splashText, "-- Found last startup item, application done!" & @CRLF, 1)
            ;   EndIf
            ;EndIf
        ;   GUISetState()
        ;Next
    Until $splashMsg = $GUI_EVENT_CLOSE
    Exit
EndFunc

Func someFunc($sArgs, $iArgs)
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0