Stop an active TIdHTTP.Get ?

Posted on 2004-11-27
Last Modified: 2008-01-09

I'm using the indy TIdHTTP component to download files via an asp page.  It works great, updating progress bars and time elapsed/remaining etc..

The only problem I have is that I cannot figure out how to stop an active download.  As per most operations that involve waiting, there's a cancel button, but I can't make it work!

I've tried using disconnect, disconnectSocket and even freeing and recreating the object, but these all cause either an access violation or an annoying dialog that says the connection was closed gracefully, but then makes the app hang.

Can anyone advise me on this?

Thanks a lot,

Question by:Jaymol
    LVL 22

    Expert Comment


    Try to use Threads
    then you can stop or terminate the thread
    also when you using threads your application will not be blocked while downloading (due to the blocking mode that indy use)

    LVL 6

    Author Comment

    Yeah, thanks.  I've thought of that and am trying to avoid it due to laziness : )

    Hopefully, there'll be a simpler solution, but if not, I guess I'll be threading stuff tonight!


    LVL 12

    Accepted Solution

    raise an EAbort in the idhttp component's OnWork event

    in the cancel button you'd do smtn like:

    OnWork event:
    if FCanceled then

    to use one thread and still have app responsivnes you can add Application.ProcessMessage in the OnWork event or put a TIdAntiFreeze on a form
    LVL 6

    Author Comment

    Thanks Lee.

    I have already made a thread for downloading and am going to do the same for the upload procedure, but would rather not have to rely on destroying the thread in order to destroy the objects within it.  I'll give your suggestion a go and let you know how I get on.


    LVL 12

    Expert Comment

    I use a combination of both
    it's the correct, clean and elegant way :)

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now