FoxPro Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

HTTP in a Background Thread (Asynchronous HTTP)

This example shows the technique one would follow to run any Chilkat HTTP method in a background task. (Only HTTP methods that communicate with an HTTP server are background-enabled. Methods that perform no HTTP communications return immediately and never need to be backgrounded.)

Download Chilkat HTTP ActiveX

LOCAL loHttp
LOCAL lnSuccess
LOCAL n
LOCAL i

loHttp = CreateObject('Chilkat.Http')

*  Any string unlocks the component for the 1st 30-days.
lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loHttp.LastErrorText)
    QUIT
ENDIF

*  To run an HTTP method asynchronously in a background thread, set
*  the UseBgThread property equal to 1
loHttp.UseBgThread = 1

*  For those programming languages that support event callbacks:
*  events are not fired when a task is running in the background thread.
*  Instead, Chilkat has added the "event log" mechanism.  While the
*  background task is running, events that normally would've been fired
*  are accumulated in the event log.  Your application may periodically check
*  the event log to keep track of the progress of the background task.
*  To enable event logging, set the KeepEventLog property = 1
loHttp.KeepEventLog = 1

*  Start an asynchronous HTTP download in a background thread.
*  The method will return cktrue if the task was successfully started.
*  Note: When the UseBgThread property = 1, all methods involving
*  HTTP communications will be asynchronous.  These methods include:
*  SynchronousRequest, QuickGetStr, QuickGet, PostUrlEncoded, XmlRpc,
*  XmlRpcPut, QuickPutStr, QuickGetObj, QuickDeleteStr, PutText,
*  PutBinary, PostBinary, PostMime, GetHead, DownloadAppend, etc.
lnSuccess = loHttp.Download("http://www.chilkatsoft.com/download/ChilkatJava.zip","ChilkatJava.zip")
IF (lnSuccess <> 1) THEN
    ? loHttp.LastErrorText
    QUIT
ELSE
    ? "Initiated asynchronous HTTP download..."
ENDIF

*  Write a loop to wait for the background task to complete.
*  Your application would typically do something different than this --
*  after all... there's no point in doing the task asynchronously if your application
*  is simply going to wait for it to complete -- that's the same as doing it synchronously,
*  and that could've been achieved by a single call to the http.Download method
*  with the UseBgThread = 0.
*  However... we do this here for the purpose of demonstration...
DO WHILE (loHttp.BgTaskRunning = 1)
    *  Show the events in the event log that have accumulated so far...

    n = loHttp.EventLogCount
    IF (n > 0) THEN

        FOR i = 0 TO n - 1
            ? loHttp.EventLogName(i) + ": " + loHttp.EventLogValue(i)
        NEXT
        loHttp.ClearEventLog()
    ENDIF

    *  In some programming languages, you might wish to handle user-interface events
    *  For example, in C#  you might call Application.DoEvents()

    *  Sleep .1 seconds -- to keep the CPU from being 100% busy...
    loHttp.SleepMs(100)
ENDDO

*  Once the background task has completed, check it for success/failure:
IF (loHttp.BgTaskSuccess) THEN
    ? "Background task completed successfully."
ENDIF


Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser