Hello,
I have built a .NET remoting solution (SingleCall) that writes a file to
disk, then waits for a second file in a specified folder (using the
FileSystemWatch er.WaitForChang ed method). When the component is called by two
peers at the same time, two FileSystemWatch ers are created (one for each
peer). They are both monitoring the same path (but for different files -
using different filters). The following code illustrates the scenario:
using System;
using System.IO;
using System.Threadin g;
class clsMain {
static void Main() {
Thread thread1 = new Thread(new ThreadStart(t1) );
Thread thread2 = new Thread(new ThreadStart(t2) );
thread1.Start() ;
thread2.Start() ;
Console.ReadLin e();
}
static void t1() {
FileSystemWatch er fs1 = new FileSystemWatch er(@"c:\files", "file1");
if (!fs1.WaitForCh anged(System.IO .WatcherChangeT ypes.All, 10000).TimedOut ) {
System.Console. WriteLine("f1 found!");
} else {
System.Console. WriteLine("f1 not found!");
}
}
static void t2() {
System.IO.FileS ystemWatcher fs2 = new
System.IO.FileS ystemWatcher(@" c:\files", "file2");
if (!fs2.WaitForCh anged(System.IO .WatcherChangeT ypes.All, 10000).TimedOut ) {
System.Console. WriteLine("f2 found!");
} else {
System.Console. WriteLine("f2 not found!");
}
}
}
When copying file1 and file2 to the path c:\files (which are monitored by
the two FileSystemWatch ers) only one of them receives a signal, the other one
simply timesout.
Please advice,
Best Regards,
Fredrik Johansson 1 1821
I solved the problem by creating my own FileSystemWatch er (non-derived) and
thus, pulled the contents of a folder every n second.
"Fredrik Johansson" wrote: Hello,
I have built a .NET remoting solution (SingleCall) that writes a file to disk, then waits for a second file in a specified folder (using the FileSystemWatch er.WaitForChang ed method). When the component is called by two peers at the same time, two FileSystemWatch ers are created (one for each peer). They are both monitoring the same path (but for different files - using different filters). The following code illustrates the scenario:
using System; using System.IO; using System.Threadin g;
class clsMain { static void Main() { Thread thread1 = new Thread(new ThreadStart(t1) ); Thread thread2 = new Thread(new ThreadStart(t2) ); thread1.Start() ; thread2.Start() ;
Console.ReadLin e(); }
static void t1() { FileSystemWatch er fs1 = new FileSystemWatch er(@"c:\files", "file1"); if (!fs1.WaitForCh anged(System.IO .WatcherChangeT ypes.All, 10000).TimedOut ) { System.Console. WriteLine("f1 found!"); } else { System.Console. WriteLine("f1 not found!"); } }
static void t2() { System.IO.FileS ystemWatcher fs2 = new System.IO.FileS ystemWatcher(@" c:\files", "file2"); if (!fs2.WaitForCh anged(System.IO .WatcherChangeT ypes.All, 10000).TimedOut ) { System.Console. WriteLine("f2 found!"); } else { System.Console. WriteLine("f2 not found!"); } } }
When copying file1 and file2 to the path c:\files (which are monitored by the two FileSystemWatch ers) only one of them receives a signal, the other one simply timesout.
Please advice, Best Regards, Fredrik Johansson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ken Madden |
last post by:
I want to create multiple fileSystemWatchers in a Windows Service to
constantly watch multiple folders for file creations and then execute
certain code based on these actions. The problem is that these directories
are not part of the same directory so I cannot use the subfolder flag. The
number of folders also has to be dynamic so I cannot simply create a certain
number of FileSystemWatchers with different paths. I am going to pull a...
|
by: zfeld |
last post by:
I am serializing an object to XML and writing it to disk. whenever a change
to my object occurs I call the save function to re-write to disk (see code
below). I am monitoring the directory where this write is being done using a
FileSystemWatcher.
My problem is that my Watcher.Changed callback is always invoked twice.This
is causing me to process the change twice (causing a performance hit).
I am filtering to only be notified for...
|
by: Jeff Reed |
last post by:
I am experiencing the the problem outlined the below. Unfortunately, I am using WinXP and I not sure if I can apply the solution due to lack of security control
Any feed back would be apreciated
http://support.microsoft.com/default.aspx?scid=kb;EN-US;31795
FIX: "Failed to Start Monitoring Directory Changes" Error Message When You Browse to an ASP.NET Pag
View products that this article applies to
This article was previously...
|
by: Greg Allen |
last post by:
I know this has been discussed before, and have found some documentation
about
it on the web. But nothing has fixed my problem.
I am running the 1.1 .NET framework, SP1.
I have a web application that I would like to place on a remote shared drive
on a different computer. I had problems with that, so I simplified it so
that I
am trying to use a shared drive on the SAME computer. That doesn't work
|
by: Tim D |
last post by:
Hi,
I originally posted this as a reply to a rather old thread in
dotnet.framework.general and didn't get any response. I thought it might be
more relevant here; anyone got any ideas? My questions are below...
"David Good" wrote:
> We have a network running both Win2k and Win2k3 webservers and our web sites
> reside on a UNC network share that happens to be a Network Appliance NAS.
| |
by: Mika M |
last post by:
Hi!
I've made FileSystemWatcher application to copy files from one UNC-path
(\\server\directory) into another when files appears into source path. I
made it using link http://www.developerfusion.co.uk/show/3636/2/ and
it's working fine.
Now I should make more than one instances of the FileSystemWatcher class
to watch several UNC-paths, how to do this in the same application?
|
by: daniel |
last post by:
Hi,
I am developing an application that requires me to set up file system
watchers on directories on a network drive, as well as set up
CacheDependencies in the same location for my System.Web.Caching.Cache. When
i set up the file watchers and then create the cache dependency i receive an
Exception (AccessViolationError - Attempted to read or write protected
memory). I have included a the stack trace from the exception at the end of...
|
by: keerthyragavendran |
last post by:
hi
i'm downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...
thank u
cheers
|
by: D2 |
last post by:
Hi All,
I'm just wondering whether a FileSystemWatcher object can be used to
monitor multiple directores or we have to create one FileSystemWatcher
object for each folder we need to monitor?
I want to monitor multiple folders like:
c:\windows
c:\my docs
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |