Results 1 to 4 of 4

Thread: File still being created

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    15

    File still being created

    Ok so another process creates a file. I want my program to figure out when that file is done being created. Right now it sets a file size and loops for 2 seconds and checks the file size again. This method sucks and makes the program appear locked up until the file is done being created.

    Anyone have a better way to do this? I searched several items in the forum and the only thing I found similar said to loop and keep trying to open the file until I don't get any errors. Which i'm not sure if that's anybetter.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    I'm not sure, but it's possible you could find a better way to know if file is done, using something of IO spacename (probably something as Fileexist?). Anyway you have not to loop. You can test every 2 seconds using a Timer, so your program will be awake, also if you have to say to the user (with a message box?)that some (or all)of his commands are not operating because the application is waiting for something (file created)
    Live long and prosper (Mr. Spock)

  3. #3
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    One word, "Threading"

    Start your file create/open process in a separate thread, this way your application will not appear to be locked up and if your program does anything other than work with this file your users can still perform other functions.

    Here is a Threading Tutorial from Microsoft that could prove useful.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    CyberHawke is right, anyway you obtain your app. can work also with Timer. Threading is a powerful instrument and perhaps more elegant, anyway it requests a little of careful more, but it could be the right time to start using it.
    Live long and prosper (Mr. Spock)

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