Menu

#275 Add the possibility to wait for an external program to "execute"

v1.1.x
closed
None
v1.1.1
Change Request
2018-03-01
2018-01-21
Erik Hänel
No

If the external program is a simulation it might be necessary to wait for its termination, so that its output can be read afterwards. Add this possibility to execute.

Analysis:
One has to extend the logic of the current functionality to use the ShellExecuteEx() and the WaitForSingleObject() API functions. In addition, one has to ensure that the waiting process can terminate. If the created process won't terminate, one should have the possibility to use the ESC key.

while (true)
{
    // wait 1sec and check, whether the user pressed the ESC key
    if (WaitForSingleObject(processHandle, 1000) == WAIT_OBJECT_0)
        return 0;
    if (GetAsynchCancelState())
        throw SyntaxError(SyntaxError::PROCESS_CANCELED_BY_USER, ...);
}

Implementation:
The change was implemented as proposed by the analysis [r259]. Implementation tests were passed successfully.

Documentation:
Corresponding changes were made in the language files, the find database the documentation article and the documentation index.

Tests:
The change was tested in production tests. No deviations detected. Change request implemented successfully.

Related

Commit: [r259]
Tickets: #265

Discussion

  • Erik Hänel

    Erik Hänel - 2018-01-21
    • status: open --> accepted
     
  • Erik Hänel

    Erik Hänel - 2018-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,9 @@
     If the external program is a simulation it might be necessary to wait for its termination, so that its output can be read afterwards. Add this possibility to `execute`.
    +
    +**Analysis:**
    +
    +**Implementation:**
    +
    +**Documentation:**
    +
    +**Tests:**
    
    • status: accepted --> analyzing
     
  • Erik Hänel

    Erik Hänel - 2018-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,17 @@
     If the external program is a simulation it might be necessary to wait for its termination, so that its output can be read afterwards. Add this possibility to `execute`.
    
     **Analysis:**
    +One has to extend the logic of the current functionality to use the `ShellExecuteEx()` and the `WaitForSingleObject()` API functions. In addition, one has to ensure that the waiting process can terminate. If the created process won't terminate, one should have the possibility to use the `ESC` key.
    +~~~C
    +while(true)
    +{
    
    +    // wait 1sec and check, whether the user pressed the ESC key
    +    if (WaitForSingleObject(processHandle, 1000) == WAIT_OBJECT_0)
    +        return 0;
    +     if (GetAsynchCancelState())
    +         throw SyntaxError(SyntaxError::PROCESS_CANCELED_BY_USER, ...);
    +}
    + ~~~
    
     **Implementation:**
    
    • status: analyzing --> implementing
     
  • Erik Hänel

    Erik Hänel - 2018-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,16 +2,16 @@
    
     **Analysis:**
     One has to extend the logic of the current functionality to use the `ShellExecuteEx()` and the `WaitForSingleObject()` API functions. In addition, one has to ensure that the waiting process can terminate. If the created process won't terminate, one should have the possibility to use the `ESC` key.
    -~~~C
    -while(true)
    -{
    
    -    // wait 1sec and check, whether the user pressed the ESC key
    -    if (WaitForSingleObject(processHandle, 1000) == WAIT_OBJECT_0)
    -        return 0;
    -     if (GetAsynchCancelState())
    -         throw SyntaxError(SyntaxError::PROCESS_CANCELED_BY_USER, ...);
    -}
    - ~~~
    +
    +    while(true)
    +    {
    +        // wait 1sec and check, whether the user pressed the ESC key
    +        if (WaitForSingleObject(processHandle, 1000) == WAIT_OBJECT_0)
    +            return 0;
    +         if (GetAsynchCancelState())
    +             throw SyntaxError(SyntaxError::PROCESS_CANCELED_BY_USER, ...);
    +    }
    +
    
     **Implementation:**
    
     
  • Erik Hänel

    Erik Hänel - 2018-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -3,13 +3,14 @@
     **Analysis:**
     One has to extend the logic of the current functionality to use the `ShellExecuteEx()` and the `WaitForSingleObject()` API functions. In addition, one has to ensure that the waiting process can terminate. If the created process won't terminate, one should have the possibility to use the `ESC` key.
    
    
    -    while(true)
    +    :::C++
    +    while (true)
         {
             // wait 1sec and check, whether the user pressed the ESC key
             if (WaitForSingleObject(processHandle, 1000) == WAIT_OBJECT_0)
                 return 0;
    -         if (GetAsynchCancelState())
    -             throw SyntaxError(SyntaxError::PROCESS_CANCELED_BY_USER, ...);
    +        if (GetAsynchCancelState())
    +            throw SyntaxError(SyntaxError::PROCESS_CANCELED_BY_USER, ...);
         }
    
     
  • Erik Hänel

    Erik Hänel - 2018-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -15,7 +15,9 @@
    
    
     **Implementation:**
    +The change was implemented as proposed by the analysis [r259]. Implementation tests were passed successfully.
    
     **Documentation:**
    +Corresponding changes were made in the language files, the find database the documentation article and the documentation index.
    
     **Tests:**
    
    • status: implementing --> testing
     

    Related

    Commit: [r259]

  • Erik Hänel

    Erik Hänel - 2018-03-01
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -21,3 +21,4 @@
     Corresponding changes were made in the language files, the find database the documentation article and the documentation index.
    
     **Tests:**
    +The change was tested in production tests. No deviations detected. Change request implemented successfully.
    
    • status: testing --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB