Why not use a Timer? You can set it the interval to several hours and it only ticks once.
When a timespan there should be no problem (MSDN)
Domanda
I have a project working for my clients, now I am trying to make my licencing system more advanced and I want to add one check in software.
The thing is that I want when my client is working on my software and computer clock shows some time (e.g. 12:00)
I want to open one of WinForms
for checking online licence that user have.
I thought this could be very easy to make, but since I don't want to use Timers
inside my code and make my software work slower I am now kind a stack into my own code.
This is what I've tried for now:
Dim day As String = Format(Today, "dddd")
Dim time As Date
Dim CurrHour As Integer
Dim CurrMinute As Integer
Dim CurrSecond As Integer
time = My.Computer.Clock.LocalTime 'Ive tried to use DateTime.Now here
CurrHour = time.Hour ' Get current hour value
CurrMinute = time.Minute ' Get current minute value
CurrSecond = time.Second ' Get current second value
If CurrHour = 12 AndAlso CurrMinute = 0 AndAlso CurrSecond = 30 Then
MsgBox("12 hours 0 minutes 30 seconds")
Else
Exit Sub
End If
End Sub
Is there any other way except using Timer.Tick
for this to make it working?
Soluzione
Why not use a Timer? You can set it the interval to several hours and it only ticks once.
When a timespan there should be no problem (MSDN)