473,946 Members | 9,596 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

threading using filewatcher object

Hello,

I have a file watcher object which i use to check a directory for XML
files.

When an XML file is placed in the directory i check the filename, to
make sure it for me, then parse the XML and depending on whats in it,
write an XML file back to the same directory.

Now i have this all working, but i thought the best thing i could do is
create a new thread each time the create event is fired in my file
watcher object, BUT am awful with threads, any ideas on what would be
the best approach for this?

Am i right in thinking that i would need to create a method in my class
which matches the threading delegate, e.g

public void mymethod()
{

}

and then do everything within this method?

any help would be great

thanks in advance

ADAM

Jan 25 '07 #1
1 2170

FileWatcher is inherintly multithreaded so you don't need to do
anything. Whenever FileWatcher detects a change, it triggers your
callback on a threadpool thread.

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On 25 Jan 2007 13:47:01 -0800, "ba.hons" <ba*****@gmail. comwrote:
>Hello,

I have a file watcher object which i use to check a directory for XML
files.

When an XML file is placed in the directory i check the filename, to
make sure it for me, then parse the XML and depending on whats in it,
write an XML file back to the same directory.

Now i have this all working, but i thought the best thing i could do is
create a new thread each time the create event is fired in my file
watcher object, BUT am awful with threads, any ideas on what would be
the best approach for this?

Am i right in thinking that i would need to create a method in my class
which matches the threading delegate, e.g

public void mymethod()
{

}

and then do everything within this method?

any help would be great

thanks in advance

ADAM
Jan 25 '07 #2

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

Similar topics

4
1853
by: Ron King Jr | last post by:
I have a small problem with my windows service. The first time I start the service everything works the way it's suppose to, but randomly the service fails. The jist of the service is to use the filewatcher component to watch a directory. On create only, the service will read the small XML file, process the information. Once the file is finished processing the information, it should copy the file to another directory and delete the original....
8
13502
by: Yatharth | last post by:
Hi, I m new to threading and i have successfully runed threading but i could display value on my web page ,but its working in code behind when i see it through debugger,plzzzzzzz help me here is the code below: i just wana display the simple array value stored in my array variable in my textbox thats it.
2
5224
by: Roger Twomey | last post by:
I am working on a filewatcher application. The premis is: User uploads an xml file onto the web server the filewatcher app sees the xml file filewatcher app reads the file and inserts records into our sql server filewatcher app deletes the file. I am trying to figure out the best method of doing this, so I am adding code bit by bit. Currently I have this:
0
2001
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks about in a new application I'm writing. However, when I try to use ThreadStart to do some work in a separate thread from my GUI, the methods Jason described don't seem to catch the exception. Take the following source code: Public Class...
3
2889
by: ba.hons | last post by:
Hello All. I have a filewatcher object which looks at a shared folder and when a new XML file is placed in this folder the on create method calls a method which reads the XML file and based on the content writes a new XML file to the same directory. The problem i have is as follows. If i place 10 XML files in the directory name
7
2383
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has finished. I am trying to follow this example : http://www.codeproject.com/cs/miscctrl/progressdialog.asp But although the messages still get moved, the progress window never does anything. Here is my code in full, if anybody who knows...
9
1873
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this CPU-intensive work in another thread, but of course this won't work because of Python's GIL. There's a lot of past discussion on this, and I want to bring it up again because with the work on Python 3000, I think it is worth trying
7
4185
by: tshad | last post by:
What exactly is FileWatcher doing? When you drop 100 files in a folder it is watching, it normally will fire of the event 100 times. In my case, I do all my processing on the first event so I don't need to reinitialize all my variables for each file. Normally 50 - 100 files will be dropped in the folder at a time. If I get an error, in my code it moves out to my try/catch code in the service - handle it and then exit. Then the next...
3
1098
by: Aussie Rules | last post by:
Hi I create a number of filewatchers in my code. I have a need to delete some of the file watchers, but can not figure out how to do this without stopping the application and restarting. To create the filewatcher I have this code.... There doesn't seem to be a name or index for the filewatch so how do I delete one? Dim watcher As New FileSystemWatcher()
0
9976
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,...
0
11554
Oralloy
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...
0
11143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11328
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
9875
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...
1
8241
isladogs
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...
0
6100
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6320
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4526
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.