From: Mr. X. on
Hello.
I see on some components that I can do I.e:
addHandler myButton.click, eventHandlerSub

But for Timer (is it on System.Timers ?) I cannot handle the tick event.
How can I by some code handle the tick event of the timer ?

Thanks :)
From: Armin Zingler on
Am 03.04.2010 07:16, schrieb Mr. X.:
> Hello.
> I see on some components that I can do I.e:
> addHandler myButton.click, eventHandlerSub
>
> But for Timer (is it on System.Timers ?) I cannot handle the tick event.
> How can I by some code handle the tick event of the timer ?


The System.Windows.Forms.Timer does have a Tick event.
System.Timers.Timer and System.Threading.Timer are something different.


--
Armin
From: Family Tree Mike on
On 4/3/2010 1:16 AM, Mr. X. wrote:
> Hello.
> I see on some components that I can do I.e:
> addHandler myButton.click, eventHandlerSub
>
> But for Timer (is it on System.Timers ?) I cannot handle the tick event.
> How can I by some code handle the tick event of the timer ?
>
> Thanks :)

Here is an example with System.Timers.Timer:

Sub THandler()
Console.WriteLine("Tick")
End Sub
Sub Main()
Dim t As New System.Timers.Timer
AddHandler t.Elapsed, AddressOf THandler
t.Interval = 250
t.Start()
Console.WriteLine("Waiting...")
Console.ReadKey()
End Sub


--
Mike
From: Cor Ligthert[MVP] on
You know that for a form application a windows.forms.timer gives mostly less
trouble than the system (for windows service and console application) or the
threading timer (as it says for multithreading)


"Mr. X." <nospam(a)nospam_please.com> wrote in message
news:OILyfzu0KHA.6104(a)TK2MSFTNGP06.phx.gbl...
> Hello.
> I see on some components that I can do I.e:
> addHandler myButton.click, eventHandlerSub
>
> But for Timer (is it on System.Timers ?) I cannot handle the tick event.
> How can I by some code handle the tick event of the timer ?
>
> Thanks :)

From: Mr. X. on
Yes, I have thought about that ...
I indeed use the system.windows.forms.timer, and not as I have mentioned
mistakenly System.Timers.timer
(what is the best approach ?)

What I need to do is to create a token string, and for each 20 minutes I
need to re-create a token string.
There are two main functions :
1. Create the token-string.
2. Check if the token-string is a valid one.

There may be a problem when checking the token. This may be a minor problem,
but it may be, because there is a probability that I can check the token
while re-create a new token.

I have thought of such solutions (at first glance) :
1. First scenario, which holds the time (in ticks) in a variable.
A major function, which only by this function I can do (by sending it
parameters) : create the token string, or check the token, with interval of
one second. (It calculate and "knows" a specific time where it should be
re-create the token - only at 20 minutes interval and act as a dispatcher.
2. Do a thread. I don�t know if VB is good language for that, but thread is
something else different then using timers.

In both solutions, I need a protected memory, which cannot be changed
synchrony.
Another problem, which make things more complicated, I should think about :
the scenario of creating the token string, and the scenario of checking it
don't occur at the same main process (there are two different program).

I need also, a function, which cannot run asynchrony more then one process
(it may be a dll, but I don't know if dll may be asynchrony for two
process).

Thanks :)