Archived Forum Post

Index of archived forum posts

Question:

iOS ftps background threading

Dec 17 '12 at 15:50

Hello,

Is there any way to prevent the UI from locking up when establishing a connection, changing directories, or creating directories? I have checked your docs but I was unable to find any relevant information regarding background threading for these methods. I would like to display an activity indicator while the client connects, but it appears the methods above are locking up the main thread and preventing the UI from updating.


Accepted Answer

If your program has one thread of execution, then the UI won't update while your application code is running. A thread is a path of execution -- the CPU is executing one instruction after the other. If the CPU is in the midst of executing the instructions of your application code (or the instructions within a library called by your application code), then it's not running the instructions for updating the UI. Control must return back from the UI event handler (such as a button press event) for the UI to update.

There are two options available:

1) Create a background thread to run the task. This could be used for any long-running task. It is not Chilkat specific. Anything can be put in a background thread.

2) Use event callbacks. See http://www.chilkatforum.com/questions/292/event-callbacks-in-ios-objective-c


Answer

I was able to get the progress working smoothly for uploads, but what callback do I use to get notified when an FTP session is connected? The only thing I could find was ConnectComplete in CkoSocketProgress.h.

The setEventCallbackObject requires CkoFtp2Progress, which does not match the base class for CkoSocketProgress.