Inline..
--
Manoj G [.NET MVP]
Site:
http://www15.brinkster.com/manoj4dotnet
Blog:
http://msmvps.com/manoj/
"Simon Harvey" <simon.harvey@the-web-works.co.uk> wrote in message
news:udB1DXL6DHA.1592@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hi everyone,
>
> I need to make a service that monitors a directory for changes in the[/color]
files[color=blue]
> contained within it. I have two questions:
>
> 1. I'm going to be using a FileSystemWatcher object to do the monitoring -
> but do I need to somehow involve another thread to allow the service to do
> other stuff as well, or is another thread created automatically when the
> FileSystemMonitor object is created?[/color]
[Manoj] Yes, the monitoring happens on a seperate thread from the thread
pool. This is done automatically. You dont need to worry.
[color=blue]
>
> 2. Because I'm creating a service, and not an application, do I need to
> worry about threading at all?[/color]
[Manoj] Depends on what all purposes you use the service for. If your
service just does file system monitoring, then you dont really have to
bother much about threads, unless there is some objects shared between the
main thread and the thread executing the event handler. In this case, you
may need to synchronize these resources.
[color=blue]
>Is it possible that my service could try and
> steal all the processors resources, or does the operating system
> automatically give each service a shot of the processor such that I don't
> have to worry about it?[/color]
[Manoj] Oh yes, if you dont respect resources, you can screw the performance
of the system (spawing tens of threads with a high priority for instance).
And the OS schedules threads, not processes. A service is just another
process which has one or more threads.
For your simple file system monitor, this is not much of a problem
[color=blue]
>
> Sorry, I'm a bit unkowledgeable in this area - I'm making an application[/color]
for[color=blue]
> my boss though and I don't want to arse it up! :-)
>
> Thanks to nayone and everyone who can help
>
> Kindest Regards
>
> Simon
>
>[/color]