-
Random Timer?
I'm attempting to update our database at random intervals but for some reason I can't figure out why RndNo.Next(5000, 60000) doesn't seem to be Random at all for each time the callback is performed. I think that value gets set once and the Threading.Timer uses the value obtained from the first RndNo.Next(5000, 60000).
Private m_thread As Threading.Timer
Private RndSd As Random = New Random
Private RndNo As Random = New Random(RndSd.Next())
Sub Main()
m_thread = New Threading.Timer(New Threading.TimerCallback AddressOf UpdateDatabase), Nothing, 0, RndNo.Next(5000, 60000))
End Sub
Public Sub UpdateDatabase()
'update the database
End Sub
Does anyone have a clue how to make the call to UpdateDatabase truly random event firing someitme between 5 and 60 seconds?
-
Seems you may want to perhaps fill a byte array with a sequence of random numbers...
http://www.dotnet247.com/247referenc...tutorialid=106