possible Windows Service

bpayne111

Junior Contributor
Joined
Feb 28, 2003
Messages
325
Location
BFE
I have an idea for a windows service but i'm not sure how well it will work out. So i'd like to run the idea by some of you gurus for speculation.
First off I am an avid chess player and try to play as much as my day will allow. My games are all saved on my computer. Many chess players do the same so that they may analyze thier games etc...
My idea is to create a windows service that would search for files that contain chess games and add them to a database. I'd like it to check for files that have added new games to them as well.
My idea to accomplish this is to create a windows application that prompts a user for different folders and files to 'watch' for chess games. I understand that using the root directory would be horrendous on any CPU therefore only folders and files not drives would be allowed in the list.
Once a user has specified where his games may be found these places would be added to a text file.
I'd like to have my Service app search for this certain file every hour or so and search for games in these places and add them to a database.
Is this a good idea to get me started in windows services?
if i can get it to work it would be a great benefit to me and my chess life. I have many ideas that could stem from this application as well.
Any suggestions or comments for this application are greatly appreciated.

ps
i know that i can not use a graphical interface for my service... this is why another application will write to a file instead. That way the service can find the file and search accordingly. issues concerning file access are running through my head as well...

brandon
 
thank you that's somethign i was curious of...
i was considering making this a Windows App before making it a Service for easier debugging...
Does that sound like a good plan?
 
bpayne111 said:
thank you that's somethign i was curious of...
i was considering making this a Windows App before making it a Service for easier debugging...
Does that sound like a good plan?
yep, and what you can do is, when you do install it as a service, build the solution in debug mode and then in vs.net u can debug as you would a regular app buy using 'attach to process'.
 
cool

also is threading gonna be something i need to know before i get this working right?

i have some concerns about the FileSystemWatcher
how many filesystemwatcher objects is too many? after reading the overview on it. it seems perfect except i'm considering restricting my user to a certain number of files and folders to watch.

brandon
 
you'll probably need 1 FileSystemWatcher object for every folder you want to watch

You can probably do 1 FileSystemWatcher per drive and set the FileSystemWatcher.Path to the root of the drive. That might raise events on file events within nested directories of the root drive, but I'm not sure if it works like that.


basically, if you tell the FileSystemWatcher to watch C:\
and I move C:\WINDOWS\...\..\...\...\somefile.tmp to C:\TEMP\..\...\overhere.tmp, will it trigger the FileSystemWatcher.


Threading would be nice. Maybe have 1 thread dedicated to the FileSystemWatcher operations.
 
yes i was aware of having multile FileSystemWatchers. My concern is if i have some file system watchers watching the root directory and some folders won't that bog down my system a ton?
i know nothing about threading. What would i do with the threads? and how would they help my app?
thanks for the help your time is appreciated
i'm trying to explore this program fully before diving in head first

brandon
 
Well, I guess I'm answering my own question for this 1. THere's a FileSystemWatcher.IncludeSubdirectories property to listen in on subfolders.

I think 1 FileSystemWatcher.Filter for each root drive should be sufficient with FileSystemWatcher.IncludeSubdirectories set to true. Just make sure you set a filter to something other than *.* and specify which events you want to be notified about (Changed, Created, Deleted, Error, Renamed).. look at the public events.


Threads allow you to execute code simulatenously, so if you ever need that to happen, you use threads. Too many threads will hurt your apps performance though. I can't give you a # because it depends on what each thread is doing.
 
so watching the entire root directory for one file type (in my case .pgn) all the time will not bog down the system? that is my biggest concern.
If that is the case i can dump the whole user input completely.

thanks
brandon
 
i would think not
I'm assuming the the os knows about all file operations being performed and it will just notify the FileSystemWatcher when it needs to. So basically, the FileSystemWatcher will not be polling the directory every .01 ms, or sec looking for file changes, it will instead tell the OS to notify it on certain events.
 
For the best efficiency use the NotifyFilter property to only receive the changes of the specified kind. If a lot of files change the buffer into which the component recevies messages might overflow, so its a good thing to limit the change notification if you dont need them all.
 
Ignore this

*** ignore this**** i fixed it

well more problems
i began my project declaring a new file system watcher

C#:
		#region Declarations
		FileSystemWatcher _watcher = new FileSystemWatcher("c:\","*.pgn");

		#endregion
		
		private void frmMain_Load(object sender, System.EventArgs e)
		{
}

the errors is in "c:\" the '\' is not acknoledged because it is used to format strings. how do i input the '\' char correctly in code?

i'm hitting the help files now i know this is a simple bug and i should alraedy know how to fix it but i don't.

brandon
 
Back
Top