Skip to content

libcURL.MultiHandle.PerformOnce

Andrew Lambert edited this page Aug 15, 2015 · 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.

##Notes Calling MultiHandle.PerformOnce executes curl_multi_perform once and reads all messages emitted by libcURL during that operation. All EasyHandle and MultiHandle events will be raised on the thread which calls PerformOnce. PerformOnce will not return until all event handlers have returned.

Under no circumstances should PerformOnce be called from EasyHandle or MultiHandle events. Doing so will raise an IllegalLockingException.

The TransferComplete event will be raised for any completed easy handles.

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

If the stack is not being processed, begins processing the stack. If the stack is already being processed, raises an IllegalLockingException.

##Example

  Dim curl As New libcURL.EasyHandle
  curl.URL = "http://www.example.com/"
  ' this event must be handled in order to receive downloaded data
  AddHandler curl.DataAvailable, AddressOf DataAvailableHandler 

  Dim multi As New libcURL.MultiHandle  
  If Not multi.AddItem(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

##See also

Clone this wiki locally