Hi,
I wrote a simple windows service that includes a FileSystemWatch er.
After building and installing the service (installutil) I notice that
the service executes twice. I included a write to the application
eventlog in OnStart ("service has started and is ready to watch the
filesystem") and this results in two entries in the eventlog.
Also, the handler for the FileSystemWatch er seems to be fired twice if
something happens with a file the service is watching.
I checked the machines services and in the task manager but I see only
one instance of the service running.
I'm a newbie at this, so I probably missed something obvious... Could
this be the properties of the service that were not correctly configured?
Any ideas?
Thx,
Tom 4 2366
"Tom Van den Brandt" <gu*******@guin eapig.bewrote in message
news:uJ******** ******@TK2MSFTN GP06.phx.gbl...
Hi,
I wrote a simple windows service that includes a FileSystemWatch er.
After building and installing the service (installutil) I notice that
the service executes twice. I included a write to the application
eventlog in OnStart ("service has started and is ready to watch the
filesystem") and this results in two entries in the eventlog.
Also, the handler for the FileSystemWatch er seems to be fired twice if
something happens with a file the service is watching.
I checked the machines services and in the task manager but I see only
one instance of the service running.
I'm a newbie at this, so I probably missed something obvious... Could
this be the properties of the service that were not correctly configured?
Any ideas?
Thx,
Tom
Tom, often we look at code and miss that what we are trying to accomplish is
often sabotaged by lack of observation or object/control events. Two of the
great debugging tools I have discovered are sleep and alcohol. Without
seeing your code, it is not possible to give advice. I have solved many
problems just by putting the problem to bed for a while, and come back to it
when ones' emotional state has changed. Cheers
Well,
I had some sleep in the meantime...
And this is what I came up with:
I had the code to write to the application event log in OnStart double.
So part of the problem is corrected. Still, the FilesSystemWatc her
seems to fire twice. Maybe I don't understand its mechanics well enough.
This is what I have in OnStart:
Me.SMSFileWatch er.Path = Path
Me.SMSFileWatch er.IncludeSubdi rectories = False
Me.SMSFileWatch er.NotifyFilter = IO.NotifyFilter s.LastWrite
Me.SMSFileWatch er.Filter = "freebee.jr n"
Me.SMSFileWatch er.EnableRaisin gEvents = True
AddHandler SMSFileWatcher. Changed, AddressOf OnChanged
And this in OnChanged:
My.Application. Log.WriteEntry( "An SMS has arrived!")
send("An SMS has arrived")
send passes the message to clients on the network...
So, everytime I open the file, change it and save it, I have the "An SMS
has arrived!" message twice in the Application event log.
Am I doing this correctly?
Thx!
Tom
Harry schreef:
"Tom Van den Brandt" <gu*******@guin eapig.bewrote in message
news:uJ******** ******@TK2MSFTN GP06.phx.gbl...
>Hi,
I wrote a simple windows service that includes a FileSystemWatch er. After building and installing the service (installutil) I notice that the service executes twice. I included a write to the application eventlog in OnStart ("service has started and is ready to watch the filesystem") and this results in two entries in the eventlog.
Also, the handler for the FileSystemWatch er seems to be fired twice if something happens with a file the service is watching.
I checked the machines services and in the task manager but I see only one instance of the service running.
I'm a newbie at this, so I probably missed something obvious... Could this be the properties of the service that were not correctly configured?
Any ideas?
Thx,
Tom
Tom, often we look at code and miss that what we are trying to accomplish is
often sabotaged by lack of observation or object/control events. Two of the
great debugging tools I have discovered are sleep and alcohol. Without
seeing your code, it is not possible to give advice. I have solved many
problems just by putting the problem to bed for a while, and come back to it
when ones' emotional state has changed. Cheers
Tom Van den Brandt wrote:
Still, the FilesSystemWatc her seems to fire twice.
Maybe I don't understand its mechanics well enough.
This is what I have in OnStart:
Me.SMSFileWatch er.Path = Path
Me.SMSFileWatch er.IncludeSubdi rectories = False
Me.SMSFileWatch er.NotifyFilter = IO.NotifyFilter s.LastWrite
Me.SMSFileWatch er.Filter = "freebee.jr n"
Me.SMSFileWatch er.EnableRaisin gEvents = True
AddHandler SMSFileWatcher. Changed, AddressOf OnChanged
Did you declare SMSFileWatcher "WithEvents "?
If so, VB will have /automatically/ wired-up the OnChanged Event for you
and your AddHandler statement will simply add /another/ handler to that
event; it won't "undo" or "replace" an existing one.
And this in OnChanged:
I'm not entirely sure why but, whenever I've used the FileSystemWatch er,
I've had to allow for multiple events in rapid succession - you seem to
get duplicate "change" events even if the file only changes once.
HTH,
Phill W.
Phill W. schreef:
Tom Van den Brandt wrote:
>Still, the FilesSystemWatc her seems to fire twice. Maybe I don't understand its mechanics well enough.
This is what I have in OnStart:
Me.SMSFileWatch er.Path = Path Me.SMSFileWatch er.IncludeSubdi rectories = False Me.SMSFileWatch er.NotifyFilter = IO.NotifyFilter s.LastWrite Me.SMSFileWatch er.Filter = "freebee.jr n" Me.SMSFileWatch er.EnableRaisin gEvents = True AddHandler SMSFileWatcher. Changed, AddressOf OnChanged
Did you declare SMSFileWatcher "WithEvents "?
Even when I comment out the Addhandler line and the EnableRaisingEv ents
line (and put the code in OnChanged in
Private Sub SMSFileWatcher_ Changed
The code is still executed twice.
I'm thinking that for some reason the filewatcher is firing the event
twice...
Thx for your suggestions!
>
If so, VB will have /automatically/ wired-up the OnChanged Event for you
and your AddHandler statement will simply add /another/ handler to that
event; it won't "undo" or "replace" an existing one.
>And this in OnChanged:
I'm not entirely sure why but, whenever I've used the FileSystemWatch er,
I've had to allow for multiple events in rapid succession - you seem to
get duplicate "change" events even if the file only changes once.
HTH,
Phill W.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Manny |
last post by:
I have a web form "Page1.asp" and it reads data from a database, does some
calculations, and displays the records in pages. Works fine.
I have a button that displays on the page, defined as <input type="button"
onClick="OutputData()">
The OutputData() function is a javascript function that simply does this:
window.location = "Page1.asp?Flag=1";
|
by: linesh.gajera |
last post by:
Hi Guys,
I am creating a Windows service that call a routine at given interval.
Once routine is complete, windows service should wait for 5 minutes and
then call the routine again. I was using System.Timers.Timer but i had
to remove it because of known bug(842739). Now i am using
System.Threading.Timer. It executes routine fine but the delay time is
sporadic, sometimes it executes routine after 5 minutes, sometimes 10
minuete, 13...
|
by: erdem |
last post by:
hi,
i have a problem with asp.net
when i was debugging
i put breakpoint to pageload event and then i discovered that
page is loaded once (explorer shows full page correctly but continues
loading)
but then
somehow page load executes again
and then page is displayed...
but there is different thing. when page executes page load second time,,
|
by: Bob |
last post by:
I've got a .NET Framework V1.1 web service running on a Windows 2003 Server
that has 2 web methods that are called from a web application on the same
server.
One is a fire-and-forget method that executes a long running process that
results in a database being updated.
The other is a normal syncronous method that returns configuration
information to the caller.
They both log their errors to the application event log.
|
by: rajendra.mishra |
last post by:
Hi...
I have a frame(Report.htm) which has two aspx pages one for
header(header.aspx) and the other for displaying reports(Report.aspx).
when Report.htm is called Report.aspx executes twice. I have checked
for autoeventwireup. it is set to false in all the pages.cant say why
is this happenning or i suppose that for frames this is an existing
issue..
In Report.aspx i am generating an crystal report in PDF Format. I'LL
| |
by: Ashley Bryant |
last post by:
I've created a Windows Service in vb.net that is set up to run automatically,
but it never starts during system startup. I can start it manually, but I
need the service to start without any user interaction. When I originally
installed the service, I had to attempt the start twice as well from the
Service Manager. So, for some odd reason, it has to be told twice to start.
I get the following errors in the System log at startup:
...
|
by: David C |
last post by:
I spent the last four hours trying to figure out why Page_Load would
execute twice. Even stranger was that everything within if (!
IsPostBack){....} executed twice as well. There is no rhyme or reason
for that.
Here is what I found out.
When you have an ImageButton with no ImageURL set, it will always do
that. This was not the case with .NET 1.0. So if you need to
experiment with ImageButton, set something to the ImageUrl
|
by: alho |
last post by:
The web service is called by a program running on pocket pc. When to
call the web service, the first call is still ok, but for the second
or later calls, it will throw "403 Forbidden" WebException. When to
test it using the web interface on pocket IE, everything is fine.
Before there was no such problem, it only happened within a week or
so. I suspect it's caused by the server's firewall settings, but how
come the first call is ok? This...
|
by: inlovewithmusic |
last post by:
Hi ,
Ok, first of all please don't run away because of the long paragraph I am about to write, its just that there's no way for me to write the problem down in a few lines :)...
So I have written this ASP.net Web service in C# that exposes the functionality in another .dll file that I have written. The dll file has a some code that does the following ...executes an exe that collects some system information and returns it as a string. The...
|
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: 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...
|
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: 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: 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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |