Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лек 013.doc
Скачиваний:
21
Добавлен:
07.02.2015
Размер:
137.73 Кб
Скачать

Private Sub tmrShort_Timer()

Static intCt As Integer

Static strWaitingFor As String

Dim cft As CoffeeTracker

' If strWaitingFor contains a key, then the Coffee object is (or was) performing

' a task, and the static string variable contains the key of the CoffeeTracker that's watching it.

If strWaitingFor <> "" Then

On Error Resume Next

'

' If the CoffeeTracker we're waiting for has dropped out of the collection, then an error will

' occur -- meaning it's time to start another one.

Set cft = CoffeeTrackers(strWaitingFor)

If Err.Number = 0 Then Exit Sub

Else

' If the static string variable is empty, then the previous series of short tasks is complete. A

' new series is beginning, so reset the static counter (intCt).

intCt = 0

End If

If Not CancelAll Then

intCt = intCt + 1

'

' Create a CoffeeTracker to wait for the request to finish.

Set cft = NewTracker(macfe(10).ThreadID, SHORTTASKSIZE)

'

' Give the CoffeeTracker its Coffee object to watch.

Set cft.Coffee = macfe(10)

'

' Begin the task.

Call macfe(10).StartLongTask(SHORTTASKSIZE)

'

' Prepare to wait for the CoffeeTracker.

strWaitingFor = cft.ID

End If

'

' Check to see if we've completed the series of short tasks, or if we've been stopped by the Cancel button:

If (intCt >= mintHowManyShort) Or CancelAll Then

intCt = 0

tmrShort.Enabled = False

strWaitingFor = ""

End If

End Sub

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]