I have an application implemented with BackgroundWorker that periodically connects to ftp (for download and upload) using LumiSoft library. It works just fine but after a while (let's say 2 - 3 hours) the thread (backgroundworker) blocks under the Connect method (witch doesn't throw any exception). Here is the part of code that fails: try {
ftp = new FTP_Client();
logMessages = "";
logMessages += Utils.FormatLogMessage("Ftp wants to connect " +
seData.host, Utils.MessageType.Info);
worker.ReportProgress(0);
ftp.Connect(seData.host, 21);
ftp.Authenticate(seData.userName, seData.password);
logMessages = "";
logMessages += Utils.FormatLogMessage("Ftp connected to " +
seData.host, Utils.MessageType.Info);
error = false;
worker.ReportProgress(0);
System.Threading.Thread.Sleep(200);
logMessages = "";
}
catch (Exception ex)
{
logMessages = "";
if (ftp.IsConnected)
{
ftp.Disconnect();
}
ftp.Dispose();
logMessages += Utils.FormatLogMessage(ex.Message, Utils.MessageType.Error);
logMessages += Utils.FormatLogMessage("Trying to reconnect in " +
seData.recTime.ToString() + " seconds", Utils.MessageType.Info);
worker.ReportProgress(0);
Beep(500, 500);
System.Threading.Thread.Sleep(seData.recTime * 1000);
error = true;
}
This is executed at let's say every 2 minutes. So it blocks on "ftp.Connect(seData.host, 21);" and that only happens after a while. Any idea why this is happening? Please let me know if you have any suggestions. Thanks. Dana.