Skip to content

Pause and Resume

Qriist edited this page Sep 16, 2026 · 1 revision

Pausing a Transfer

Pause halts an easy handle's active download or upload while keeping the underlying connection alive:

curl.Pause(easy_handle)

Resuming a Transfer

UnPause resumes the halted transfer from the exact byte offset where it stopped:

curl.UnPause(easy_handle)

Typical Usage Pattern

Pausing is most useful within an Async pool, allowing you to temporarily freeze specific handles without breaking the connection or losing progress. The running handle count returned by Async() will reflect paused handles as no longer "running":

easyA := curl.Init()
easyB := curl.Init()

curl.SetOpt("URL", "https://example.com/large-file.zip", easyA)
curl.WriteToFile("C:\downloads\fileA.bin", easyA)

curl.SetOpt("URL", "https://example.com/another-file.zip", easyB)
curl.WriteToFile("C:\downloads\fileB.bin", easyB)

curl.ReadyAsync([easyA, easyB])

Loop {
    running := curl.Async()
    
    ; Pause one handle after a short interval or based on a condition
    if (running = 2 && !pauseStarted) {
        out .= "Pausing handle..."
        curl.Pause(easyB)
        pauseStarted := true
    }
    
    ; Resume after some time or event
    if (conditionMet && running < 2) {
        out .= "Resuming handle..."
        curl.UnPause(easyB)
    }
} Until !running

out .= "Total elapsed: " DateDiff(A_StartupTime, A_NowUTC, "Seconds") " seconds."
msgbox out

Notes

  • Pausing does not disconnect the handle. Network state is preserved.
  • Works seamlessly within Async() multi_handle pools alongside other active or paused handles.
  • See Async and Multi Interface for pool management details.

Where to Go Next

Clone this wiki locally