Results 1 to 3 of 3

Thread: [2005] File Write hangs

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Question [2005] File Write hangs

    My application runs fine 3-4 days a week out of the 6 it runs. Occasionally I never see the next step that comes after this sub so I think this is where the hang is. Today when I checked it after the hang, this file was sitting at 0Kb which indicates that it did not complete this part, and was just sitting there.

    Code:
      dim LROut As New System.IO.StreamWriter(LastRunFile, False)
                Me.bLoadFile = True
                LastRun = Date.Now
                LastHash = ComputeFileHash(AppendImaged.cBackupPath + Date.Now.ToString("MMdd") + ".txt")
                LROut.WriteLine(Date.Now.Date.ToString)
                LROut.WriteLine(ComputeFileHash(AppendImaged.cBackupPath + Date.Now.ToString("MMdd") + ".txt"))
                LROut.Close()
    I'm switching this to a Using LROut clause to see if it helps, any other ideas?

  2. #2
    Addicted Member Crushinator's Avatar
    Join Date
    Jan 2006
    Location
    The Dark Side of the Moon, MD
    Posts
    179

    Re: [2005] File Write hangs

    I would double check the logic and do a possible redesign/move some code if needed to make sure the stream gets closed.

    Other than that, maybe turn Autoflush on the streamwriter to True, which will flush the buffer after every write. Won't fix your issue, but will output to the file after each write instead of waiting for the stream to fully close.

    You may be able to open, write, and close the streamwriter each time as needed depending on your application if it is not constantly needed to write. But constantly doing that would get expensive.

    Also, just curious. Why are you assigning computed values to variables, but then in the writeline you are re-computing them? Why not just use the variables you just assigned to? Just seemed like an interesting way of doing it, just wondering, but I'm sure you have your reason.

    Wish I could be of more help.
    Using Framework 2.0, VB.Net 2005.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: [2005] File Write hangs

    I don't think I do have a good reason for recalculating the same values over again.

    looking at some of the code it does seem more inefficient than I would like to begin with, I wrote this code probably around 8 months ago. This problem only seems to be somewhat recent, as I've made changes to the supporting libraries and some to other sections of code in this project.

    This section of code happens only once, in the main form's load. There are 3 other instances of this same app that run around the same time so that may have something to do with it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width