Hi,
I was trying to do something in a Thread that starts by a
timer. I turn off the timer at the begining of the thread
incase it fires again when the thread is still running. Then
turn on the timer again before the thread finishes. To my
surprise, the timer never come alive again once it has been
turned of in the thread. To test the problem I made a simple
Windows Form project, put a Beep() in the timer. It supposed
to hear beep beep beep every one seconds, but can only hear
one. Here enclosed my clode below. Any help or suggestions are
really appreciated.
Regards,
Vincent
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal _
e As System.EventArg s) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal _
e As System.EventArg s) Handles Timer1.Tick
Beep()
Dim thr As New Threading.Threa d(AddressOf ProcTest)
thr.Start()
End Sub
Private Sub ProcTest()
Timer1.Enabled = False
'Timer1.Stop()
Timer1.Enabled = True
'Timer1.Start()
End Sub
Nov 20 '05
10 1471
Vincent,
In addition to the others comments, the following recent articles in MSDN
Magazine explain the difference between the three thread objects in .NET &
when to use each. http://msdn.microsoft.com/msdnmag/is...T/default.aspx http://msdn.microsoft.com/msdnmag/is...3/default.aspx
Hope this helps
Jay
And yes, C# will exhibit the same basic behavior.
Hope this helps
Jay
"Vincent" <Ja***@serbe.co m> wrote in message
news:Xn******** *************** ***@207.46.248. 16... Hi,
I was trying to do something in a Thread that starts by a timer. I turn off the timer at the begining of the thread incase it fires again when the thread is still running. Then turn on the timer again before the thread finishes. To my surprise, the timer never come alive again once it has been turned of in the thread. To test the problem I made a simple Windows Form project, put a Beep() in the timer. It supposed to hear beep beep beep every one seconds, but can only hear one. Here enclosed my clode below. Any help or suggestions are really appreciated.
Regards, Vincent
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal _ e As System.EventArg s) Handles MyBase.Load Timer1.Interval = 1000 Timer1.Enabled = True End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal _ e As System.EventArg s) Handles Timer1.Tick Beep() Dim thr As New Threading.Threa d(AddressOf ProcTest) thr.Start() End Sub
Private Sub ProcTest() Timer1.Enabled = False 'Timer1.Stop() Timer1.Enabled = True 'Timer1.Start() End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: brian |
last post by:
I have an ASP.Net application that uses impersonation.
This works fine for accessing/executing the application.
However, the app utilizes a timer, that when fired uses
the <machine>ASPNET identity.
In order to correct this problem I've modified the
Machine.config file in the
\Microsoft.Net\Framework\v1.1.4322 folder. However, this
didn't solve the problem; instead of using the user id and
password specified in Machine.Config, the...
|
by: Richard P |
last post by:
I need some help on timers. My app is asp.net 1.1 website running in a
shared hosting environment with a third-party service provider. I currently
request and cache 20 - 40 remote RSS feeds. When a user requests the page,
the app first tries to retrieve a feed from cache, if the feed has expired,
it goes off and request the file from the web.
If create a CacheItemRemovedCallback for each item to automatically
re-request an expired...
|
by: Paul Tomlinson |
last post by:
Question about a System.Threading.Timer object and the "state" object you
pass to it...
Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000,
1000);
I have an array of timer objects which all fire into my OnTimer( object
state ) function very nicely. I pass in an object "o" on creation of this
timer which I subsequently get passed to me in my OnTimer function. Now in
the OnTimer function I want to modify the object...
|
by: steve |
last post by:
Since System.Threading.Timer uses the threadpool to do its stuff what happens
when
(a) You try to create a timer and the thread pool is *exhausted*
(b) The timer is due to fire AND all threads in the threadpool are blocked
(deadlocked maybe)?
As a followup qn to this.. (please excuse my ignorance here) Is there one
threadpool per process or one threadpool for the *virtual machine* (ie
runtime environment, sorry haven't got a diploma...
|
by: Vincent |
last post by:
Hi,
I was trying to do something in a Thread that starts by a
timer. I turn off the timer at the begining of the thread
incase it fires again when the thread is still running. Then
turn on the timer again before the thread finishes. To my
surprise, the timer never come alive again once it has been
turned of in the thread. To test the problem I made a simple
Windows Form project, put a Beep() in the timer. It supposed
to hear beep beep...
| |
by: Stephen Rice |
last post by:
Hi,
I have a periodic problem which I am having a real time trying to sort.
Background:
An MDI VB app with a DB on SQL 2000.
I have wrapped all the DB access into an object which spawns a thread to
access the database and then displays a modal dialog which allows the user
to cancel the task, if it is taking longer than they want, and shows them a
display of how long the query has been running so far.
|
by: Ben |
last post by:
Hello everybody
I got confused by this problem for which I don't have a logical explanation.
There is a Thread (ThreadA) which receives Events from another system thread
(ThreadS). ThreadA then adds a time stamp to the received event and adds it
to a event queue. This works well (therfore not shown here). The queue fills
up.
Then I used a timer to check every millisecond for new events in the queue
and send it to another thread...
|
by: RobKinney1 |
last post by:
Hello,
Wow...I have one for you all and hopefully I am not understanding this timer
object correctly. I have a timer setup that pulses a connection through a
socket every 60 seconds. But it seems recently connections just drop off
because the timer stops firing.
My question is if there is a timeout in the timer event that just shuts down
the call if the timer event is taking too long to complete...?
|
by: Tony Gravagno |
last post by:
I have a class that instantiates two Timer objects that fire at
different intervals. My class can be instantiated within a Windows
Form or from a Windows Service. Actions performed by one of the event
handlers may take longer than the interval for either of the timers,
so it's possible for multiple events to fire "simultaneously" and for
events to queue up. I'm attempting to get the timers to sync on some
reference type object, or use...
|
by: John A. Bailo |
last post by:
From a Windows service (NET 2.0) I want to launch serveral threads in
a for loop that invokes a method using:
new Thread(delegate()
{ myMethod(248);}).Start();
Will those threads stay active even when the service reaches it Service
Timer Stop?
|
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: 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,...
|
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: 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: 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
| |