I may have mislead you a little here. You can only use MS's asynchronous programming paradigm if the API you are using supports it. edtFTPnet doesn't support it, but edtFTPnet/PRO does - it's one of the major features.
In edtFTPnet/PRO you can do things like:
private void transferButton_click(object sender, EventArgs e)
{
proFTPConnection.BeginConnect(null, null);
proFTPConnection.BeginChangeWorkingDirectory("/directory", null, null);
proFTPConnection.BeginDownloadFile(@"C:\MyDir\MyFile.dat", "MyFile.dat", null, null);
proFTPConnection.BeginClose(new AsyncCallback(OnFinished), null);
}
private void OnFinished(IAsyncResult res)
{
MessageBox.Show("Done");
}
This will connect to the server, change directory, download a file and then disconnect. It will do all this
in the background. In other words, each of the Begin...() methods will return immediately so that transferButton_click() returns instantly and your GUI doesn't freeze. Once the connection is closed, the OnFinished method will be called so that the message box can be popped up informing the user that everything's done.
However, since edtFTPnet doesn't have asynchronous methods, you'll need to use a worker thread and the multithreaded-signalling classes that you can find in System.Threading.
- Hans (EDT)