login about faq

I'm doing an http request in its own thread, which waits for it to be finished (a 180 second timeout) or for the user to abort it.

Using the background mode, I expected to be able to abort the request. Even though I call BgTaskAbort, it hangs up trying to return from the function that creates the CkHttp object. It seems that the CkHttp destructor waits for the timeout to be finished before returning. The same thing happens if I use "new" to create the CkHttp object and "delete" to delete it -- it will not return from the "delete" call until the 180 seconds has elapsed.

Here's a code snippet:

bool Request()
  CkHttp http;
  CkHttpRequest req;

/// (code to set up req...)


  CkHttpResponse *resp = 0;
  resp = http.SynchronousRequest (g_strDomain, g_nPort, true, req);
  // resp is not expected to be valid yet....

  // now start waiting
  int nCount = 0;
  BOOL fFinished = (http.get_BgTaskRunning() != true);
  // m_fGiveUp is set in another thread if Abort button clicked
  while (!m_fGiveUp && !fFinished && nCount*4 < 180)
    http.SleepMs (250);  // check once per 1/4 second
    fFinished = (http.get_BgTaskRunning() != true);

  if (!fFinished)
    // "Abort" clicked...
    m_fGaveUp = TRUE;
    return FALSE;

So, am I doing something wrong? Is there any way around this?

I also tried making the CkHttp object static, which did let it leave the function immediately, but then when another request is made it would hang up (presumably waiting for the first one to time out).

Note: I am using a version from 2010. Tried to use the new version 9.5, but wouldn't compile without changes to my code (some of the Mail/MailMan functions changed, so I'm not ready to migrate yet. If this was a known bug that has since been fixed, let me know and I'll make the effort.

asked May 02 '16 at 10:37

Cottonwood's gravatar image


You can try calling CkHttp.CloseAllConnections. I don't know if that would help.

Your code is using an older async scheme that was deprecated. It should changed to use the Chilkat standard for async (where each method that can be asynchronous has a corresponding method ending with "Async" and it returns a CkTask).

I don't know if the hangup was due to the older deprecated "Bg" methods, or if it was due to something else. I created a latest pre-release (v9.5.0.58) you can try here: http://www.chilkatsoft.com/download/preRelease/chilkat-9.5.0-x86-vc6.zip


answered May 04 '16 at 12:31

chilkat's gravatar image

chilkat ♦♦

Thank you for the response.

I don't have the CloseAllConnections function, so that must have been added later. It sounds like my only option to fix this would be to use the newer version. It's just a pain to have to go through and change a bunch of code due to class API changes, hoping it still works the same way, and then have to re-test everything. (That's why I still use VC++ 6.0 -- I don't have the manpower to rewrite and re-test an entire system that has been fine-tuned and debugged over 15 years. ;-)


answered May 04 '16 at 13:55

Cottonwood's gravatar image


I don't suppose there's a (brief) list somewhere that outlines changes that need to be done to migrate from one version to another? Like the MailMan function changes for attaching a file, etc, and how to convert the CkHttp Synchronous/Bg functions to the Async functions... The release notes (given the time to go through them) may tell me that something changed, but not how to convert my code as far as I've seen.


answered May 04 '16 at 14:13

Cottonwood's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: May 02 '16 at 10:37

Seen: 1,511 times

Last updated: May 04 '16 at 14:13

powered by OSQA