# EsbCancelProcess

Description

EsbCancelProcess() cancels an asynchronous process which has not yet completed.

Syntax

    EsbCancelProcess (hCtx)

    ByVal hCtx As Long

Parameters

hCtx | Essbase VB API context handle.

Return Value

None.

Notes

- If you use this function to cancel a process, the database may be left in an inconsistent state, with only some of the data recalculated.
- Calling this function except after initiating a successful asynchronous database operation (e.g. a calculation) will generate an error.

Access

This function requires no special privilege.

Example

    Declare Function EsbCancelProcess Lib "ESBAPIW" (ByVal hCtx As Long) As Long

    Sub ESB_CancelProcess ()
       Dim sts As Long
       Dim CalcScript As String
       Dim Calculate As Integer
       Dim ProcState As ESB_PROCSTATE_T
       Dim Items As Integer

       CalcScript = "CALC ALL;"
       Calculate = ESB_YES

       '***********
       ' Begin Calc
       '***********
       sts = EsbBeginCalc (hCtx, Calculate)
       '***********************
       ' Send Calc script
       ' It is possible to send
       ' more than one string
       '***********************
       sts = EsbSendString (hCtx, CalcScript)

       '*********
       ' End Calc
       '*********
       sts = EsbEndCalc (hCtx)

       '************************************
       ' Check process state and cancel it if
       ' it takes too long
       '************************************
       sts = EsbGetProcessState (hCtx, ProcState)
       Items = 1
        Do While ProcState.State = ESB_STATE_INPROGRESS
         Items = Items + 1
         If Items = 1000 Then

          '***************
          ' Cancel process
          '***************
          sts = EsbCancelProcess (hCtx)
         End If
       Exit Do
          sts = EsbGetProcessState (hCtx, ProcState)
       Loop
    End Sub

See Also

EsbBeginCalc()
EsbCalc()
EsbGetProcessState()
EsbImport()