473,847 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with Filesystemwatch er and Web Service

I am trying to find out if there is a way to tell if there is already a
filesystemwatch er (created by a webservice) monitoring a folder.

I have a webservice that creates a filesystemwatch er, monitors a folder and
then returns the contents of the new/changed files. However, if the client
app loses connection to the webservice without closing the filewatcher, and
then reconnects (and thus creates a new watcher), I believe I end up with two
watchers which is causing a few problems.

Is there anyway to tell if a filesystemwatch er already exists and is
watching the folder? Or that the webservice that created the first watcher is
still running?


Sep 20 '07 #1
5 5615
Hi,

Web Service is a stateless remote call, it does not have the session
feature by default unless you set EnableSession property of the
WebMethodAttrib ute. Even you enabled the session, you still have to
explicitly add the object references into the Session collection to use it.
Do you enable session in your Web Service? If so, do you add
FileSystemWatch er object into the Session collection?

Regarding your question, I do think it should not be a problem. Whether
your client is disconnected or killed abnormally, the server-side Web
Method will exit(this is the key point) and the Web Service processing
thread will return to the ThreadPool. So, all the stack references in the
Web Method will be released automatically by the stack unwind. Since the
references to the FileSystemWatch er disappeared, the FileSystemWatch er
object will be collected by the GC in future or immediately based on the GC
algorithm. So, once the WebMethod exited, the FileSystemWatch er objects are
guaranteed to be collected by GC, no leak will occur.

If you wanted to ensure the FileSystemWatch er object is collected
immediately, I would recommend you to wrap the object using C# "using"
keyword or place the FileSystemWatch er.Dispose() method calling in a
try...finally clause. This will ensure the FileSystemWatch er.Dispose() when
the WebMethod exits. FileSystemWatch er.Dispose() internally stops the
directory monitoring.

If you are not familiar with C# "using" keyword, please refer to the MSDN
link below, this is called C# deterministic cleanup:
http://msdn2.microsoft.com/en-us/lib...02(VS.80).aspx

Finally, I am curious about how do you use FileSystemWatch er in a
WebMethod? Based on my knowledge, FileSystemWatch er will monitor a
directory consistently, but WebMethod is one-off stateless calling from
client, FileSystemWatch er will be collected after the call. Do you spawn a
second worker thread to use FileSystemWatch er?

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 21 '07 #2
Hi,

Have you reviewed my reply to you? Does it make sense to you? If you still
need any help, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Sep 25 '07 #3
Hi,

Thanks for your reply. It made sense and helped me make several steps forward.

Thanks again
Sep 25 '07 #4
Glad to see it helps. If you need further help or have any other concern,
please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Sep 25 '07 #5
Hi

I'm working on a VB web service at the moment and want to use the
Filesystemwatch er to monitor a directory but like Jeffrey said how do you get
it to work with the web service which is stateless???

Thanks in advance, Matt

"John S" wrote:
I am trying to find out if there is a way to tell if there is already a
filesystemwatch er (created by a webservice) monitoring a folder.

I have a webservice that creates a filesystemwatch er, monitors a folder and
then returns the contents of the new/changed files. However, if the client
app loses connection to the webservice without closing the filewatcher, and
then reconnects (and thus creates a new watcher), I believe I end up with two
watchers which is causing a few problems.

Is there anyway to tell if a filesystemwatch er already exists and is
watching the folder? Or that the webservice that created the first watcher is
still running?

Oct 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2197
by: Rich Miller | last post by:
Previously posted on the VB newsgroup with no replies, so any ideas appreciated. I have written a service application in VB (VS.Net 2003). On start, the service creates an object that instantiates a System.IO.FileSystemWatcher like so (the _watcher is declared at the class level as Private and no WithEvents): ' construct the file watcher _watcher = New FileSystemWatcher _watcher.Path = WatchPath _watcher.NotifyFilter =...
1
1568
by: A Hirsi | last post by:
Hi I am planning to use the filesystemwatcher to monitor an ftp site for changes to a file. I would like to download the file if it changes and process it locally. I read somewhere that I do not need a service to accomplish this and only need to write my filesystemwatcher. Do I really need to make the Filesystemwatcher program a service? Can someone please point me in the right direction.
1
4527
by: Andreas | last post by:
Hi, we have some problems with the following situation: A remote application A writes files to a directory monitored by a FileSystemWatcher-instance in application B. A creates the file with the initial ending "COPY_IN_PROGRESS" and only after successful copying the file gets renamed to its final ending "TO_DO". The FileSystemWatcher of B is set to react on the rename-event and upon recognizing an event some processing is triggered.
2
2232
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange, onRename and so on. And I had made this program as a windows service.As I know, if I delete a file from my directory, this behavior will active this program and do something what I want to do. But after I install this program as a windows service...
2
2285
by: Bonnett | last post by:
I have made a simple console application that creates a webpage from my playlist, then uploads it to my webhost. I decided to convert it to a windows service and use the FileSystemWatcher to monitor the playlist file, this is where i became stuck. I know the service detects changes to the playlist as when running the Change event of FileSystemWatcher, I add an item to the event log. I've tried making the service without including the...
2
2176
by: Sacha Korell | last post by:
I need to set up a FileSystemWatcher in my web application (to automatically process uploaded files) and I'm trying to decide where to set it up. I would like to keep it within the web app, but it needs to watch a certain folder even when nobody is making a request. I could instatiate the FileSystemWatcher in the Application_Start event, but what happens when somebody restarts the server? I guess in that case the FileSystemWatcher wouldn't...
20
4533
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
0
1232
by: Rich Miller | last post by:
Any ideas appreciated. I have written a service application in VB (VS.Net 2003). On start, the service creates an object that instantiates a System.IO.FileSystemWatcher like so (the _watcher is declared at the class level as Private and no WithEvents): ' construct the file watcher _watcher = New FileSystemWatcher _watcher.Path = WatchPath _watcher.NotifyFilter = (NotifyFilters.FileName Or NotifyFilters.Size Or...
1
3218
by: D2 | last post by:
Hi, We are using FileSystemWatcher class in a windows service to monitor a directory "d:\abc". This path is configured in a config file. When the service is running and FSW is watching this directory, user is able to open up Windows Explorer and rename d:\abc to d:\xyz. The problem here is, FSW doesnt fire any event for this hence my program doesnt know that the monitored folder has been renamed. Next time the service is started, it...
0
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9734
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7061
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4129
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.