WklTimerList
WklTimerList class
Signature
Dim myWklTimerList As WklTimerList Set myWklTimerList = Me!ControlName.Object
Summary
Scheduled tasks of a form: a delayed search, a counter refreshed periodically, a paced queue of web requests. Visible in Design view, invisible in Form view.
Parameters
None
Remarks
Events are posted and delivered after the running event procedure of the control has ended, never from inside another of its events. The tasks end when the form closes; no event arrives afterwards. See the overview for the scheduling rules.
An ActiveX control: inserted into a form in design view (Form Design › Controls › ActiveX Controls); reports are not supported. VBA reaches it through the Object property of the control, where ControlName is the name of the control on the form.
| Member | Kind | Summary |
|---|---|---|
| `Tasks` | Property | Gets the tasks of the list. |
| `Start` | Method | Starts all enabled tasks. |
| `Stop` | Method | Stops all tasks. |
| `Pause` | Method | Pauses all waiting tasks; the time left is kept. |
| `Resume` | Method | Resumes all paused tasks and every web request queue halted by an answer 401. |
| `AutoStart` | Property | Gets or sets whether all tasks start when the form opens in Form view. |
| `Running` | Property | Gets the number of runs going on. |
| `MaxParallel` | Property | Gets or sets how many background jobs may run at the same time. |
| Event | Summary |
|---|---|
| `TaskDue` | Occurs when a run of a wttEvent task is due; the event procedure is the run. |
| `TaskStarted` | Occurs when a background run sends its first web request. |
| `TaskProgress` | Occurs when a background job reports progress. |
| `TaskCompleted` | Occurs when a background run ended successfully; for a web request queue, when the queue became empty. |
| `TaskFailed` | Occurs when a background run failed. |
| `TaskCancelled` | Occurs when a background run was canceled. |
| `RequestCompleted` | Occurs when a web request was answered with a status 2xx or 3xx. |
| `RequestFailed` | Occurs when a web request was answered with another status, or not at all. |
| `RequestCancelled` | Occurs when a web request was canceled. |
| `QueuePaused` | Occurs when an answer 429 paused the whole queue. |
| `QueueHalted` | Occurs when an answer 401 halted the whole queue. |
| `QueueResumed` | Occurs when a pause ended or Resume was called. |
Code example
None
Inheritance
None
Tasks property
Signature
Property Get Tasks() As WklTimerTasks
Summary
Gets the tasks of the list.
Parameters
None
Property value: `WklTimerTasks` – The collection of tasks.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTimerList.
Start method
Signature
Sub Start()
Summary
Starts all enabled tasks.
Parameters
None
Remarks
In Design view nothing runs; the tasks start in Form view.
Code example
None
Inheritance
Declared by WklTimerList.
Stop method
Signature
Sub Stop()
Summary
Stops all tasks.
Parameters
None
Remarks
A running VBA event and a web request on the way end normally and are reported; nothing more is scheduled.
Code example
None
Inheritance
Declared by WklTimerList.
Pause method
Signature
Sub Pause()
Summary
Pauses all waiting tasks; the time left is kept.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklTimerList.
Resume method
Signature
Sub Resume()
Summary
Resumes all paused tasks and every web request queue halted by an answer 401.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklTimerList.
AutoStart property
Signature
Property Get AutoStart() As Boolean Property Let AutoStart(RHS As Boolean)
Summary
Gets or sets whether all tasks start when the form opens in Form view.
Parameters
None
Property value: Boolean – True: start with the form; False (default): start by code.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTimerList.
Running property
Signature
Property Get Running() As Long
Summary
Gets the number of runs going on.
Parameters
None
Property value: Long – The number of runs handed out and not yet ended.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTimerList.
MaxParallel property
Signature
Property Get MaxParallel() As Long Property Let MaxParallel(RHS As Long)
Summary
Gets or sets how many background jobs may run at the same time.
Parameters
None
Property value: Long – At least 1 (default 1).
Remarks
Reserved for the file, checksum, ZIP and program kinds. Each web request queue sends one request at a time; several queues run side by side.
Read/write.
Code example
None
Inheritance
Declared by WklTimerList.
TaskDue event
Signature
Event TaskDue(ByVal Key As String, ByVal RunId As Long, ByVal Tag As Variant, ByRef Cancel As Integer)
Summary
Occurs when a run of a wttEvent task is due; the event procedure is the run.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
RunId | Long | No | – | The number of the run. |
Tag | Variant | No | – | The Tag of the task. |
Cancel | Integer (by reference) | No | – | Set to True to skip the run. |
Remarks
Set Cancel to True to skip this run; an interval series goes on. A web request queue raises TaskStarted instead.
In a form module: Private Sub <ControlName>_TaskDue(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
TaskStarted event
Signature
Event TaskStarted(ByVal Key As String, ByVal RunId As Long)
Summary
Occurs when a background run sends its first web request.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
RunId | Long | No | – | The number of the run. |
Remarks
In a form module: Private Sub <ControlName>_TaskStarted(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
TaskProgress event
Signature
Event TaskProgress(ByVal Key As String, ByVal RunId As Long, ByVal Percent As Long, ByVal Text As String)
Summary
Occurs when a background job reports progress.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
RunId | Long | No | – | The number of the run. |
Percent | Long | No | – | 0 to 100. |
Text | String | No | – | A short description of the step. |
Remarks
Raised by the file, checksum, ZIP and program kinds, which are not available in this version.
In a form module: Private Sub <ControlName>_TaskProgress(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
TaskCompleted event
Signature
Event TaskCompleted(ByVal Key As String, ByVal RunId As Long, ByVal Result As Variant)
Summary
Occurs when a background run ended successfully; for a web request queue, when the queue became empty.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
RunId | Long | No | – | The number of the run. |
Result | Variant | No | – | For a web request queue Array(completed, failed): the numbers of requests completed and failed for good in this run. |
Remarks
A wttEvent run raises no TaskCompleted: its run is TaskDue.
In a form module: Private Sub <ControlName>_TaskCompleted(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
TaskFailed event
Signature
Event TaskFailed(ByVal Key As String, ByVal RunId As Long, ByVal Number As Long, ByVal Description As String, ByVal WillRetry As Boolean)
Summary
Occurs when a background run failed.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
RunId | Long | No | – | The number of the run. |
Number | Long | No | – | The error number. |
Description | String | No | – | The error text. |
WillRetry | Boolean | No | – | True when the run is repeated after RetryDelay. |
Remarks
Raised by the file, checksum, ZIP and program kinds; a web request reports RequestFailed.
In a form module: Private Sub <ControlName>_TaskFailed(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
TaskCancelled event
Signature
Event TaskCancelled(ByVal Key As String, ByVal RunId As Long, ByVal Reason As WklTimerCancelReason)
Summary
Occurs when a background run was canceled.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
RunId | Long | No | – | The number of the run. |
Reason | `WklTimerCancelReason` | No | – | Why: wcrCancel, wcrStop, wcrTimeout or wcrClose. |
Remarks
In a form module: Private Sub <ControlName>_TaskCancelled(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
RequestCompleted event
Signature
Event RequestCompleted(ByVal Key As String, ByVal Id As Long, ByVal Tag As Variant, ByVal Status As Long, ByRef Result As WklHttpResult)
Summary
Occurs when a web request was answered with a status 2xx or 3xx.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
Id | Long | No | – | The Id of the request. |
Tag | Variant | No | – | The Tag of the request. |
Status | Long | No | – | The HTTP status. |
Result | `WklHttpResult` (by reference) | No | – | The answer: Text, Status, Header(Name), Headers. |
Remarks
Further requests may be added to the queue here, for example the requests that need the key returned in the answer.
In a form module: Private Sub <ControlName>_RequestCompleted(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
RequestFailed event
Signature
Event RequestFailed(ByVal Key As String, ByVal Id As Long, ByVal Tag As Variant, ByVal Status As Long, ByVal Description As String, ByVal WillRetry As Boolean, ByRef Result As WklHttpResult)
Summary
Occurs when a web request was answered with another status, or not at all.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
Id | Long | No | – | The Id of the request. |
Tag | Variant | No | – | The Tag of the request. |
Status | Long | No | – | The HTTP status; 0 when no answer came. |
Description | String | No | – | Method, address without query, and status or cause; never a header value or a body. |
WillRetry | Boolean | No | – | True when the request is sent again. |
Result | `WklHttpResult` (by reference) | No | – | The answer when one came (for example a problem+json message), otherwise Nothing. |
Remarks
Only a request without answer and an answer 429 are sent again; any other answer, also 5xx, is reported as it is, because a repetition could do the work twice. A second 401 in a row for the same request is reported here, and the queue halts again.
In a form module: Private Sub <ControlName>_RequestFailed(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
RequestCancelled event
Signature
Event RequestCancelled(ByVal Key As String, ByVal Id As Long, ByVal Tag As Variant, ByVal Reason As WklTimerCancelReason)
Summary
Occurs when a web request was canceled.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
Id | Long | No | – | The Id of the request. |
Tag | Variant | No | – | The Tag of the request. |
Reason | `WklTimerCancelReason` | No | – | Why: wcrCancel, wcrStop, wcrTimeout or wcrClose. |
Remarks
A request whose connection was closed may have changed data at the service; its outcome is unknown.
In a form module: Private Sub <ControlName>_RequestCancelled(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
QueuePaused event
Signature
Event QueuePaused(ByVal Key As String, ByVal Reason As String, ByVal ResumeAt As Date)
Summary
Occurs when an answer 429 paused the whole queue.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
Reason | String | No | – | The cause, “429”. |
ResumeAt | Date | No | – | The local time the queue goes on. |
Remarks
The pause is the time in Retry-After (seconds or an HTTP date); without it, RateWindow, or 60 seconds.
In a form module: Private Sub <ControlName>_QueuePaused(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
QueueHalted event
Signature
Event QueueHalted(ByVal Key As String, ByVal Id As Long, ByVal Status As Long, ByVal Headers As String)
Summary
Occurs when an answer 401 halted the whole queue.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
Id | Long | No | – | The Id of the halted request. |
Status | Long | No | – | The HTTP status. |
Headers | String | No | – | The response headers as text, one per line. |
Remarks
Sign in again on the main thread, set the shared headers and call Resume: the halted request is sent first.
In a form module: Private Sub <ControlName>_QueueHalted(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.
QueueResumed event
Signature
Event QueueResumed(ByVal Key As String)
Summary
Occurs when a pause ended or Resume was called.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | String | No | – | The key of the task. |
Remarks
In a form module: Private Sub <ControlName>_QueueResumed(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTimerList.