|
-
Sep 16th, 2003, 09:29 AM
#1
Thread Starter
Frenzied Member
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
-
Sep 16th, 2003, 09:21 PM
#2
Sleep mode
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 .
-
Sep 17th, 2003, 09:22 AM
#3
Thread Starter
Frenzied Member
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.
-
Sep 17th, 2003, 10:05 AM
#4
Sleep mode
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|