Dear Dan,
It seems I made some mistakens in my previous post. The TransferProgress is not always firing. Just there are lots of TransferProgress events in the message queque waiting for your consuming.
In this version we added some multi-threading features into the Ftp Component, like non-blocking event firing. It is to say, the TransferProgress, TransferBroken, and TransferCompleted will be fired in another threading, instead of the same thread as the version before. Therefore, if there lots of events sent to the System Message queque, and your event handler cannot consume them fast enough, you will found the situation like the event keeps firing.
For example, in the pervious version, which the event producer (FtpClient instance) and event consumer (your event handler) are in the same thread, the FtpClient fires a TransferProgress event, and then it stops, the TransferProgress will work, and then return to the FtpClient, the FtpClient continue to download files. And then, the FtpClient fires another TransferProgress event, and stops again. so on ...
The code works behind like:
while (is download completed?)
{
download file from website
//stop the download, call your event handler. after your event handler return, the loop will continue
transferProgressCallback(TransferStatus.Downloading, totalReceived, len);
}
However, in the new version, we change the blocking event mode to non-blocking mode for the performance concern. The download process will keep going, since it does not wait for the event handler return. and so the event firing and download is faster than the blocking mode.
The code works behind like
while (is download completed?)
{
download file from website
//use another thread to fire the transferprogress event, therefore not blocking here, the loop gos on
}
In short, the TransferProgress event is not continue to fire after you break the network. Just too many TransferProgress are here waiting your processing.
Some suggestions for the resume-broken senario:
- listen the TransferBroken event handler and do the resume in the handler
- do not listen the TransferProgress event , which will hurt some performance, even in the non-blocking mode
- if you Have to listen the TransferProgress event, it is better to do it in anthoer thread