Jump to content

Recommended Posts

Posted

I have a script I put together for some end users to retrieve records from a database to use for their tests.  There are about 12 queries I run to ensure I get Valid records but 3 of them are rather long running, about 5 minutes each.  so when it gets to these queries after a few minutes the GUI freezes and shows (Not Responding).

It always recovers but the (Not Responding) is rather alarming for the end users and it also seems to halt the fancy Animated GIF I have which was supposed to show the query was still running.

Is there something I can maybe add to AdlibRegister to fool windows into thinking it's still working?

 

Thanks for any ideas you might be able to offer.

Mike

 

Posted

It hangs right after $RS.Open($sSQL, $Conn) while the query is running.  Once data starts coming in, the UI recovers and moves on to the next one.

 

Here is one of the long running functions.  I chopped the Query part out.

Func _Query_UserIDs($Conn, $iRecords)

    $sSQL = 'Select DISTINCT Top ' & $iRecords & ' Big Query that works but takes a while'

    $RS = ObjCreate("ADODB.Recordset")              ;Create a new recordset to hold this modules RefID's
    $RS.CursorType = 3                              ;Type of connection 3 = get data at time of query, all changes from others while connected will be ignored.
    $RS.Open($sSQL,$Conn)                           ;Perform the SQL Query on the connected Database

    ;Start working through the records returned
    if $RS.EOF then

        Return SetError(1, 1, 0)                    ;Error, no records were returned.

    else

        $RS.MoveFirst
        $iRecordCount = $RS.RecordCount

        With $RS
            If .RecordCount Then

                While Not .EOF


                    $sOutputValue &= @CRLF & "ModuleName|" & StringStripWS(.Fields("RefID").Value, 3)
                    .movenext

                WEnd

            EndIf
        EndWith

    Endif

    $RS.close

    Return $iRecordCount

EndFunc ;_Query_UserIDs

 

  • Developers
Posted

Ok, so you created your own SQL request with a com object.

The only "easy" solution I can think of is to re-shell your own script to perform the sql statement and in the mean time monitor the newly shelled script instance in the main script. Look at AutoI3Wrapper that does something similar for a different purpose.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • 4 years later...
Posted

I wanted to add a response.  I realize that this topic has not seen a response in a while.  You can get AutoIT to not lock the GUI process by using the AdLibRegister and the AdLibUnRegister functions.  It requires a bit of creativity in your organization, but not too much.  i.e. place the logic in a function and keep your global's status in mind as it executes.

 

 

Func ProcessWebSiteTests()
;add function to library
    AdlibRegister ("TestWebsites")
EndFunc

Func TestWebsites()
    Global  $sDesiredCapabilities
    $sDesiredCapabilities = SetupEdge()
    GUICtrlSetState($testWebButton, $GUI_DISABLE)
    TestWebsiteAvailability($fergusonImage, $fergusonProgress, "https://www.test.com")
    TestWebsiteAvailability($buildImage, $buildProgress, "https://btest.com")
    TestWebsiteAvailability($supplyImage, $supplyProgress, "https://test.com")
    TestWebsiteAvailability($pipeImage, $pipeProgress, "https://mydigitalspace.sharepoint.com/sites/mypipeline")
    TestWebsiteAvailability($workImage, $workProgress, "https://www.test.com/test/d/home.htmld")
    TestWebsiteAvailability($powerImage, $powerProgress, "https://app.powerbi.com/home")
    TestWebsiteAvailability($vcollectImage, $vcollectProgress, "http://test:9090/VoiceConsole/login.action?error=true")
    TestBlockedWebsite($blockedImage, $blockedProgress,  "https://dosgames.com")
    GUICtrlSetState($testWebButton, $GUI_ENABLE)
    _WD_Shutdown()   
    ;unregister to prevent continuous execution
    AdlibUnRegister("TestWebsites")
EndFunc

 

  • Developers
Posted (edited)
  On 8/23/2021 at 11:26 PM, meeoun said:

ou can get AutoIT to not lock the GUI process by using the AdLibRegister and the AdLibUnRegister functions. 

Expand  

This is only true when the active function is none-blocking!

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Yeah, I made an assumption when I was able to use the adlibregister method to interrupt a process and remove the not responding message.  However, the help text for adlibregister indicates that the main code is blocked while executing, so that is a bit confusing to read.  In my case, I was able to use it to stop the GUI from indicating not responding and to also interrupt the function and make it exit.  In other languages, you usually multithread so that the gui thread does not tie up.  I understand that AutoIT never intends to introduce multi-threading, which is fine, perhaps helper functions that abstract it in specific ways?  It might be nice if AutoIT provided a method that worked like adLibRegister, but just ran the function on its own thread.  Would be pretty easy to use and not tie up the gui thread that autoit must be running.  

Posted (edited)

btw.

@BigDaddyO did you solve your problem with ADO ?

In your case it is related to the fact that you are opening RS in sync mode.
 

$RS.Open($sSQL,$Conn)                           ;Perform the SQL Query on the connected Database

This mean ADO "steal focus from AutoIt" on entire SQL statement procesing and delivering data to object.

As you said:

$sSQL = 'Select DISTINCT Top ' & $iRecords & ' Big Query that works but takes a while'

This query processing "takes a while", and for this time period, AutoIt processing capabilities is stolen by ADO internal processing.
 

I think that you should open recordset in asynchronic way with adAsyncFetchNonBlocking

Take a look here:
https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/open-method-ado-recordset?view=sql-server-ver15

Then you will be able to watch on Events :
https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/fetchprogress-event-ado?view=sql-server-ver15
https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/fetchcomplete-event-ado?view=sql-server-ver15

I mean focus should back to AutoIt processing just after you use:
 

$RS.Open(.....)

and after FetchComplete event will be fired (which you must check in a loop) then you can start analyze data row by row.

If you are still interested in solving this problem, I will gladly try to help you solve this problem using my ADO.au3 UDF.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...