Hello,
I'm having a go at writing my first Windows Service in VB.NET and I'm
having a problem. I have it installed ok and started the service
sucessfully, I can stop it, and restart it fine, the problem is it
doesn't appear to be running any of my code whatsoever.
I dropped a Timer Control on the designer, set it to disabled with an
interval of 5000, went to the code window and on the OnStart Event,
typed in:
Timer1.Enabled= True
But the .Tick event never fires at all. I've tested this out by
putting a MsgBox in the Onstart event, and sure enough the service
stops right away becuase of that. I then cut it out of there, and put
it as the first thing in Timer1's .Tick event, the service runs
without stopping itself...its not hitting the Msgbox
I even tried another approach, creating a new thread in the OnStart
event, and Starting the thread, but again, the thread never starts.
It will run anything I put in the Onstart event, unless it involves
running any other Subs or Functions.
Any Help?
Scott 3 9543
I'm still stuck, someone must have written a windows Service in VB.NET
to get back to basics, I made this...
Protected Overrides Sub OnStart(ByVal args() As String)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As_
System.EventArg s) Handles Timer1.Tick
'this event is never fired
End Sub
(created as a window service)
It compiles, installs and I can start the service, but Timer1_tick is
never fired. I put the Timer1 onto the designer window rather than
create one in code.
Scott
On Fri, 04 Jun 2004 15:31:41 GMT, Scott H wrote: I dropped a Timer Control on the designer, set it to disabled with an
Which timer control? There are several available. The Windows Forms Timer
is probably not appropriate. Try the System.Timers.T imer
it as the first thing in Timer1's .Tick event, the service runs without stopping itself...its not hitting the Msgbox
Is the service set up to allow interaction with the desktop? If not, the
msgbox code may be executing but you just may not see it.
To debug, try setting the timer interval to something larger like 10
seconds then start the service and then attach the debugger to it and put a
breakpoint inside the timer tick code. That should show if it is hitting
the timer code or not.
--
Chris
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
You have to create the timer in code;
Private mvTimer As New System.Timers.T imer(5000)
Protected Overrides Sub OnStart(ByVal args() As String)
AddHandler mvTimer.Elapsed , AddressOf mvTimer_Elapsed
mvTimer.Enabled = True
' or mvTimer.Start (not sure of the exact difference yet...)
End Sub
Private Sub mvTimer_Elapsed (ByVal pSender As Object, ByVal pArgs As
System.Timers.E lapsedEventArgs )
'this event had better fire!!
MessageBox.Show ("I fired!!", "Yay!", MessageBoxButto ns.OK,
MessageBoxIcon. Information)
End Sub
(add mvTimer.Enabled = False (or mvTimer.Stop) and RemoveHandler.. . to Sub
OnStop for completeness)
_______________ ______________
The Grim Reaper
"Scott H" <x@y.com> wrote in message
news:h9******** *************** *********@4ax.c om... I'm still stuck, someone must have written a windows Service in VB.NET to get back to basics, I made this...
Protected Overrides Sub OnStart(ByVal args() As String) Timer1.Enabled = True End Sub
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As_ System.EventArg s) Handles Timer1.Tick 'this event is never fired End Sub
(created as a window service) It compiles, installs and I can start the service, but Timer1_tick is never fired. I put the Timer1 onto the designer window rather than create one in code.
Scott This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ray |
last post by:
Hi,
I just wrote a windows service application to call a function of another
object periodically. I used System.Server.Timer and I found that it works
fine within the first 2 hours but the onTimer event wouldn't be raised again
after few hours. I checked the msdn and Microsoft claims that it is a bug in
their .net framework as follows:
http://support.microsoft.com/default.aspx?scid=kb;en-us;842793
|
by: andrewcw |
last post by:
I am trying to do a windows service with C#. I am using as
a base the VB.NET article in VS, but I thing the
WITHEVENTS timer notation is a delegate. Can anyone
provide sample code & anh hints. Thanks Andrew
|
by: Jesper Stocholm |
last post by:
I have created a simple service which just copies a fil to a new file
with a new name on certain intervals (the service implements a timer).
I have no problems installing the service and the log-entries I have
created on stop() and start() in the eventlog works fine as well.
However - the actual task is never executed. I catch the execution of
the tick and in the finally-block I write to the eventlog as well. But
only one entry is creates...
|
by: Dhilip Kumar |
last post by:
Hi all,
I have developed a windows service using the windows service project
template in VS.NET. I have used three controls in the service, a timer,
performance counter and a message queue control. The service will "sleep"
for 'n' seconds using the timer control and whenever the timer_elapsed event
occurs, I use the performance counter object to determine availability of
few resources. Based on the availability of resources, I use the...
|
by: Doug Stiers |
last post by:
I have a VB app that I'm installing as a Windows Service. I want a
subroutine in the app to run every 30 minutes during business hours. How do
I do this in VB? I set the startup type as automatic so it's always running.
Is there some kind of timer event I can use?
Thanks,
Doug
| |
by: Trevor |
last post by:
Argh! This problem is driving me nuts! Can you help?
In November of 2003, I installed a web service on Windows Server 2003 built
in VB.NET for v1.1.4322 of the framework. It contains a timer
(System.Timers.Timer) which has an interval of 24 hours. Actually, it reads
a time like 2AM out of the config file, and calculates the time between the
start of the service to 2AM, and sets the timer. When the timer expires, it
re-reads the...
|
by: Tom |
last post by:
Using multiple System.Timers.Timer objects in a Windows Service for
performing multi-thread activities in a periodic fashion. Timers are
AutoReset=false, to only have a single timer execution thread running at any
given moment.
Typically, timers will have an interval of 5 to 15 minutes. Conditionally,
the interval may be set to 1 second (1000 ms) before the next call to
Timer.Start().
Here is the question: if the interval is one...
|
by: Lemune |
last post by:
Hello everyone.
I'm using vb 2005. I'm creating program that run as service on windows.
And in my program I need to use timer, so I'm using timer object from
component. I try my source code on another project that use windows
form and it work. But when I implement my source code on my program
that run as service on windows (I have change the code so it would work
on service but I still use timer object from component), and it doesn't...
|
by: Ollie Riches |
last post by:
I'm looking into a production issue related to a windows service and
System.Timers.Timer. The background is the windows service uses a
System.Timers.Timer to periodically poll a directory location on a
network for files and then copies these files to another location (on
the network) AND then updates a record in the database. The file
copying is performed before the database update because the file
system is not transactional.
The code...
|
by: dm3281 |
last post by:
I'm really starting to hate writing services -- or trying to, anyway.
Why do I need to rename my project to the service name?
Why do I need to set the "ServiceName" property to my service name?
Why do I need to set a property within my code to the service name?
Are all these required or am I just doing this for consistency purposes?
|
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: 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: 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: 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...
| |