Archived Forum Post

Index of archived forum posts

Question:

Connect locks program

May 19 '14 at 08:23

Hello!

i am using async calls to avoid locking the interface and do other work while uploading with the ftp2 library. Problem is the connect function! if some settings or the login data is wrong then this call locks the interface until the connection times out.. (60 seconds)

is there a way to avoid having all locked for 60 seconds? thanks


Answer

If your program is single-threaded, then Yes -- a call into a method will block the program's main thread form servicing the UI because it is busy within the method that is being called.

There are several solutions, depending on your programming language:

  1. Explicitly create a background thread and make the call there, which allows the main (foreground) thread to continue servicing the UI.
  2. Use AbortCheck event callbacks (with the HeartbeatMs property set to a small value, such as 20ms) to update the UI from within AbortCheck callbacks.
  3. Set the ConnectTimeout property to a smaller value (smaller than the default of 60 seconds).