• Creator
    Topic
  • #4196
    lp_irovetz
    Participant

    Hi Advansys team,

    I try to improve this piece of code


    Creation of a query = OK
    qw.start

    ‘ Wait for the end of the Query
    qwend = false
    Do While not qwend
    qwend = QW.Completed
    if not qwend then
    utilities.Timer(1)
    end if
    loop

    Many time, i’d got errors with utilities.Timer(1). Mad( Memory violation, crash of GW, syntax error on these line ,…)

    How to remplace it ? I’d like to wait until qw.completed but i don’t want to spend computer process power in the loop. Confused

    Any idea ?

    L.P. Irovetz
    Arcane GroupWare

  • Author
    Replies
  • #7454
    MA
    Participant

    Use utilities.DoEvents() inside the loop to process any pending messages in Windows application message queue. If the query not completed after some waiting period then you may need to exit from the loop…

    qwend = false
    waitCounter = 0

    ‘ Wait for the end of the Query
    Do While not qwend

    Exit after 30 seconds and issues a HALT to the GroupWise Search Engine
    if (waitCounter > 30) then
    QW.Stop()
    utilities.doevents
    exit do
    end if

    ‘qwend = QW.Completed
    if not qwend then
    utilities.Timer(1)
    waitCounter = waitCounter + 1
    utilities.doevents
    end if

    loop

    Thanks
    MA

    #7452
    Support 1a
    Participant

    Thanks MA.

    My experience with Object API Queries has been that they sometimes never return. I haven’t used one in some time, so Novell may have improved them since I last tried. We tend to use Find() instead of queries for this reason.

    Advansys Support

    #7455
    lp_irovetz
    Participant

    Sorry but the problem is not in Query process but with utilities.Timer()

    Thanks MA. “utilities.doevent” seems to help query to search asynchronously but problem persist.
    Thanks Support. But how used “find” with documents ?

    The problem is more present with low connection between clien and PO.
    In local mode, nearly no problems
    With low connection (even 1Mo SDSL mode), the only way is to increase time
    – Using utilities.Timer(2) rather utilities.Timer(1) – but we don’t stop crashs

    Is there a way to work around “utilities.Timer” ?

    Thanks

    L.P.

    #7453
    Support 1a
    Participant

    Utilities.Timer() using a Windows Timer object, which puts the thread from which it is called to ‘sleep’ for the specified time. Formativ runs in the same thread as the GroupWise client, so using a timer will also put GroupWise to sleep. (The GroupWise Query runs in it’s own thread). I suspect the errors you are seeing are a result of a threading/timing issue resulting from putting the main GroupWise thread to sleep while the query thread is running.

    One solution (in theory) would be to run the query in a different thread and wait for it to return. You can’t do this in Formativ, but you could do it with a 4GL like VB, Delphi, C++, etc. However, Novell’s Object API documumentation indicates that free-threading (the ability to use any object created on any thread from any other thread) is not recommended. Our experience is that it should not be attempted at all. This means you can’t use a multi-threaded approach to solving this type of problem.

    Unfortunately the only approach I can think of would be to not use a timer, and simply sit in a loop calling Utilities.DoEvents() to ensure the Windows message queue is processed while the query is being executed.

    You may be able to obtain more information about using the Object API Find() and Query() objects from Novell, either directly or via the Developer forums they host.

    Regards,

    Advansys Support

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.