Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I'm understanding you correctly this <code>while(!stopped)</code> loop is the loop that is running for several hours? If that is the case, where are you terminating your ftp connection if anywhere? The only time you close it in the code you've posted is if an exception is thrown, otherwise you simply dereference the object and create a new one which is a pretty serious resource leak and at least contributing to the problem if not causing it.</p> <p>Also it seems that ftp is globally accessible. Are you accessing it anywhere using a different thread? Is the object thread safe??</p> <p><strong>EDIT:</strong></p> <p>The biggest issue I see here is design. Not that I'm trying to bag on you or anything but you've got all sorts of operations intermixed. Threading, logging and ftp access code all in the same function.</p> <p>What I would recommend is restructuring your program. Create a method much like the following:</p> <pre><code>// Called by thread void MyThreadOperation() { while(!stopped) { // This is poor design in terms of performance. // Consider using a ResetEvent instead. Thread.Sleep(5000); try { doFTPDownload(); } catch(Exception ex) { logMessage(ex.ToString()); } } } </code></pre> <p><code>doFTPDownload()</code> should be self contained. The FTP object should be created and opened inside the function when it is called and prior to it finishing it should be closed. This same concept should be applied to <code>logMessage()</code> as well. I would also recommend using a database to store log messages instead of a file so that locking issues don't complicate matters.</p> <p>I know this isn't an answer in that you may still experience issues since I can't say for certain what could be the cause. However I'm confident with a little design restructuring you will be much better able to track down the source of the problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload