Hi!
I havea control that display messages...
I added a timer to it
Every time a noew mesaage should be displayed I do the following:
Private sub ShowMsg(message as string)
Me.lblStatus.Text = message
tmrStatus.Start()
tmrStatus.Interval = 3000
tmrStatus.Enabled = True
End Sub
Private Sub tmrStatus_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmrStatus.Tick
If statusColor.Equals(Color.Lime) Then
statusColor = Color.Green
Else
statusColor = Color.Lime
End If
Me.lblStatus.Refresh()
If flashTime = MaxFlashes Then
flashTime = 0
tmrStatus.Stop()
Else
flashTime += 1
End If
End Sub
The timer handler is never called.. ShowMsg work ok... what's wrong here?
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------ 12 1441
Very, Very strange
The starter method of the timer (ShowMsg) is in fact an event raised from
another thread....
Seems that first time it is raised, the timer run, but second time the timer
tick handler is never called
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Crirus" <Cr****@datagroup.ro> wrote in message
news:e2*************@tk2msftngp13.phx.gbl... Hi!
I havea control that display messages... I added a timer to it Every time a noew mesaage should be displayed I do the following:
Private sub ShowMsg(message as string) Me.lblStatus.Text = message tmrStatus.Start() tmrStatus.Interval = 3000 tmrStatus.Enabled = True End Sub
Private Sub tmrStatus_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrStatus.Tick If statusColor.Equals(Color.Lime) Then statusColor = Color.Green Else statusColor = Color.Lime End If Me.lblStatus.Refresh() If flashTime = MaxFlashes Then flashTime = 0 tmrStatus.Stop() Else flashTime += 1 End If End Sub
The timer handler is never called.. ShowMsg work ok... what's wrong here?
-- Ceers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
Third precisation:
The second thread that try to start timer, raise the event and the timer run
and then make a call to wbclient.UploadData
While the UploadData didnt returned yet, the timer tick is triggered
When wbclient.UploadData return, I try to run the timer again and calling
threadis paused.
This time, timer tick is never fired...
I tried to fire the tick event with a mouse click and work just fine...
Only that second call from within the secod thread dont work
Make any sense?
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Crirus" <Cr****@datagroup.ro> wrote in message
news:e2*************@tk2msftngp13.phx.gbl... Hi!
I havea control that display messages... I added a timer to it Every time a noew mesaage should be displayed I do the following:
Private sub ShowMsg(message as string) Me.lblStatus.Text = message tmrStatus.Start() tmrStatus.Interval = 3000 tmrStatus.Enabled = True End Sub
Private Sub tmrStatus_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrStatus.Tick If statusColor.Equals(Color.Lime) Then statusColor = Color.Green Else statusColor = Color.Lime End If Me.lblStatus.Refresh() If flashTime = MaxFlashes Then flashTime = 0 tmrStatus.Stop() Else flashTime += 1 End If End Sub
The timer handler is never called.. ShowMsg work ok... what's wrong here?
-- Ceers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
* "Crirus" <Cr****@datagroup.ro> scripsit: I havea control that display messages... I added a timer to it
A 'System.Windows.Forms.Timer'?
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
If I set the interval property before call for Start, first raise of the
tick event never occur...
Only when I call just start from second thead event handler
In fact, my goal is to signal to user that a connection to internet is on
the way and wether the connection was succesfull or failure...the tick event
should just make a short flash efect by changing the backfround of the
status control
But I cant use that timer as I whould espect
"Crirus" <Cr****@hotmail.com> wrote in message
news:u5*************@TK2MSFTNGP11.phx.gbl... Yes, there are anothers? That server one?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:#M*************@TK2MSFTNGP11.phx.gbl... * "Crirus" <Cr****@datagroup.ro> scripsit: I havea control that display messages... I added a timer to it
A 'System.Windows.Forms.Timer'?
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
Yes, there are anothers? That server one?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:#M*************@TK2MSFTNGP11.phx.gbl... * "Crirus" <Cr****@datagroup.ro> scripsit: I havea control that display messages... I added a timer to it
A 'System.Windows.Forms.Timer'?
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
If I set the interval property before call for Start, first raise of the
tick event never occur...
Only when I call just start from second thead event handler
In fact, my goal is to signal to user that a connection to internet is on
the way and wether the connection was succesfull or failure...the tick event
should just make a short flash efect by changing the backfround of the
status control
But I cant use that timer as I whould espect
"Crirus" <Cr****@hotmail.com> wrote in message
news:u5*************@TK2MSFTNGP11.phx.gbl... Yes, there are anothers? That server one?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:#M*************@TK2MSFTNGP11.phx.gbl... * "Crirus" <Cr****@datagroup.ro> scripsit: I havea control that display messages... I added a timer to it
A 'System.Windows.Forms.Timer'?
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
Hi MVP Herfried, A 'System.Windows.Forms.Timer'?
I see you post questions for details in many issues but then never come back
for a final answer...
Is just a sign you are alive around here?
I whould like you to give an answer instead of just hope for help, even
considering many differend approches...
Should I bother to give you details in the future?
herzliche Grüße,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl... * "Crirus" <Cr****@datagroup.ro> scripsit: I havea control that display messages... I added a timer to it
A 'System.Windows.Forms.Timer'?
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
Hi Crirus,
I tried to figure out what is your problem but could not real get it, I
thought that I did something you are saying now and I know that it did give
me a lot of headache.
Some weeks ago I have copied some code that Armin did contribute to this
group. I still did not use or look deep to it, but it is from Armin, so I
think it will work fine.
I think to remember me, that the problem was from someone who did want to
make a progressbar going from out another thread.
Here is the code, take a look yourself, because you have seen what I wrote
about my knowledge from it. (But in a first sight I think you can use it)
Cor
\\\By Armin Zingler
Private m_Thread As MyThread
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
m_Thread = New MyThread
AddHandler m_Thread.Progress, AddressOf OnProgress
AddHandler m_Thread.Done, AddressOf OnDone
m_Thread.Start()
End Sub
Public Delegate Sub ProgressDelegate(ByVal Progress As Integer)
Private Sub OnProgress(ByVal Progress As Integer)
If Me.InvokeRequired Then
Me.Invoke(New ProgressDelegate( _
AddressOf OnProgress _
), New Object() {Progress})
Else
Me.Button1.Text = Progress.ToString
End If
End Sub
Private Sub OnDone()
m_Thread = Nothing
End Sub
////
Class MyThread
Public Event Progress(ByVal Progress As Integer)
Public Event Done()
Private m_Thread As Thread
Public Sub Start()
m_Thread = New Thread(AddressOf ThreadStart)
m_Thread.Start()
End Sub
Private Sub ThreadStart()
Dim i As Integer
For i = 1 To 100
Thread.Sleep(100)
RaiseEvent Progress(i)
Next
RaiseEvent Done()
End Sub
End Class
///
Well, the timer issue is solved... I just used a wrong type of timer..
thread timer fit to my problem
Seems that Windows timer get stucked in multithreading environment....
Anyway hte rogress bar thing could help me in another future issue..
thanks
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Cor" <no*@non.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl... Hi Crirus,
I tried to figure out what is your problem but could not real get it, I thought that I did something you are saying now and I know that it did
give me a lot of headache.
Some weeks ago I have copied some code that Armin did contribute to this group. I still did not use or look deep to it, but it is from Armin, so I think it will work fine.
I think to remember me, that the problem was from someone who did want to make a progressbar going from out another thread.
Here is the code, take a look yourself, because you have seen what I wrote about my knowledge from it. (But in a first sight I think you can use it)
Cor
\\\By Armin Zingler Private m_Thread As MyThread
Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click
m_Thread = New MyThread AddHandler m_Thread.Progress, AddressOf OnProgress AddHandler m_Thread.Done, AddressOf OnDone m_Thread.Start() End Sub
Public Delegate Sub ProgressDelegate(ByVal Progress As Integer)
Private Sub OnProgress(ByVal Progress As Integer) If Me.InvokeRequired Then Me.Invoke(New ProgressDelegate( _ AddressOf OnProgress _ ), New Object() {Progress}) Else Me.Button1.Text = Progress.ToString End If End Sub
Private Sub OnDone() m_Thread = Nothing End Sub //// Class MyThread Public Event Progress(ByVal Progress As Integer) Public Event Done()
Private m_Thread As Thread
Public Sub Start() m_Thread = New Thread(AddressOf ThreadStart) m_Thread.Start() End Sub
Private Sub ThreadStart() Dim i As Integer For i = 1 To 100 Thread.Sleep(100) RaiseEvent Progress(i) Next RaiseEvent Done() End Sub
End Class ///
* "Crirus" <Cr****@hotmail.com> scripsit: Yes, there are anothers? That server one?
'System.Threading.Timer' and 'System.Timers.Timer', but both of them do
not have a 'Tick' event. So I assume you use the Windows Forms timer.
This timer is designed for use in Windows Forms and must be used on a
form. Instance members are not thread safe.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
* "Crirus" <Cr****@datagroup.ro> scripsit: A 'System.Windows.Forms.Timer'?
I see you post questions for details in many issues but then never come back for a final answer...
See my reply to your other answer. Sometimes I miss older posts because
my newsreader skips old threads. I feel sorry for that! I have
increased the number of recent threads now.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Ok, thanks, I found that Thread timer fit to my needs...
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O1**************@tk2msftngp13.phx.gbl... * "Crirus" <Cr****@datagroup.ro> scripsit: A 'System.Windows.Forms.Timer'?
I see you post questions for details in many issues but then never come
back for a final answer...
See my reply to your other answer. Sometimes I miss older posts because my newsreader skips old threads. I feel sorry for that! I have increased the number of recent threads now.
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Seth |
last post by:
For some reason my service works fine except that it will create the
file in my c drive, but will not write to the file.
Sorry if this is a duplicate post, i have found some that ask the same...
|
by: Tom |
last post by:
When using system.timers.timer, which should one use to start/stop the
timer? Start/Stop, or Enabled=True/False? If what I read is true, both
really do the same thing, so I don't know if there is...
|
by: martin1 |
last post by:
All,
timer interval is 60 sec, i want ot set up timer start 15 sec later after
minute. for example if current time is 2:30:00, the timer starts 2:30:15,
then timer loop procedure every minute...
|
by: martin1 |
last post by:
Hi, All,
My question is how to set up timer start 15 sec past minute. It always start
15
sec past minute. For example, if current time is 8:30:45, the timer starts on
8:31:15 am; if current...
|
by: dhulapati |
last post by:
I cant get the timer working with the windows service. I have the
timer set to 3600 ms. It polls only for Start and Stop but not at
intervals. The timer1.tick event handler is called at the...
|
by: Boki |
last post by:
Hi All,
I have a timer, if my data queue Q has data, the timer should start
work, if there is no data in Q, the timer should stop.
However, there is an event can fire timer to start.
Should I...
|
by: shashwat_k11 |
last post by:
Hi,
I am writing web service and I want to read a file only once when I
start the web service. How can I do that? Which event fires exactly
onece when we launch web service?
I am reading...
|
by: Andreas Hohn |
last post by:
Hi,
what is the right way to start a timer?
timer.enabled = true
or
timer.start()?
|
by: seegoon |
last post by:
Hi to all.
I have a application that receives data via the serial port. I don't
know the number of bytes that are going to
be coming in. It could be 10 up to 150. (9600 baud)
I have decided to...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |