Results 1 to 4 of 4

Thread: Troubles with service reading a file.

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Troubles with service reading a file.

    I have a service that needs user-defined start up arguments. Reading that the registry isn't recommended any longer, I have a xml doc that holds the values.

    My problem is, when the machine starts up (my service auto-starts), the values are not read from the properties file correctly. More precisely, values have their defaults (integers are 0, strings are ""). If I stop, then restart the service, the values are read in just fine.

    Any idea what's going on, or a better way to accomplish?

    TIA,
    Mike

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Put a timer , set interval to something like 20 seconds , put your initialization code that takes values from the file . This maybe will make sure that all files are accessible and in their places ready for any process. Then , just turn it off or disable it . I don't know what kind of service you are working on but it's worth a try .

  3. #3

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    An enabled timer with too short of an interval was my problem. In the OnStart method, I read in some info. When the Timer exectues, it creates a class with some of these values.

    What was happening was the timer was executed before the properties were read in.

    So I changed the timer to not enabled, do my stuff in the OnStart method, whose last line enables the timer.

    Thanks, Pirate.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    A different approach ,

    Put a flag in the file named flagR =1 . Make a loop in your code , that checks for this flag in specified interval . If it's not equal to 1 (which means it couldn't get the proper value) , then loop again till you get flag =1 , then just procced your code to read the whole bundle of values . I didn't test this but it's just a thought I had in the midnight .

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