Skip to content

libcURL.MultiHandle.PerformOnce

Andrew Lambert edited this page Nov 26, 2022 · 17 revisions

libcURL.MultiHandle.PerformOnce

Method Signature

 Function PerformOnce() As Boolean

Return Value

Returns True until all transfers have completed. Call PerformOnce again until it returns False.

Remarks

Each invocation of this method will perform as much of each outstanding transfer as is immediately possible and then return. The TransferComplete event will be raised for any completed transfers.

Unlike MultiHandle.Perform, this method will raise all EasyHandle and MultiHandle events on the calling thread instead of always on the main thread.

Under no circumstances should PerformOnce be called, directly or indirectly, from EasyHandle or MultiHandle events. Doing so will create a recursive loop and overflow the call stack.

Example

This example sets up a transfer using the EasyHandle class, and then adds it to an instance of MultiHandle. PerformOnce is called multiple times by a simple loop that yields between each call.

  Dim curl As New libcURL.EasyHandle
  curl.URL = "http://www.example.com/"
  Dim output As New MemoryBlock(0)
  Dim outstream As New BinaryStream(output)
  curl.DownloadStream = outstream

  Dim multi As New libcURL.MultiHandle  
  If Not multi.AddTransfer(curl) Then
    MsgBox("cURL error: " + libcURL.FormatMultiError(multi.LastError))
  End If
  
  Do Until Not multi.PerformOnce() ' do a little bit of the transfer
    App.YieldToNextThread
  Loop
  outstream.Close

  If curl.LastError <> 0 Then
    MsgBox("cURL error: " + libcURL.FormatError(curl.LastError))
  End If

See also

Clone this wiki locally