What DateTime to use for all clusters in a network

  • Thread starter Thread starter deskcheck1
  • Start date Start date
D

deskcheck1

Guest
Hi,

I'm writing a Windows Form app using VS2019 that needs to check the datetime column of a SQL Server table and compare that with Today's datetime. The database table is updated from multiple clusters in the network.

However, the clusters don't have their time in sync: some are two hours off, some are some minutes off. Because there are so many computers in this network, it's impossible to keep their time in sync, especially when there are power outages or other unplanned shutdown.

How do I do this? How can I query them from a reference point of ONE date and time? As example, I have a Timer that has an event handler that performs some action at 1-second interval. Then I want that for every 10 seconds, it performs another function.

Timer1 Code snippet:

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
UpdateProgressBar()
UpdateCpuChart()
CreateNetTrafficChart()
UpdateDiskUsage()
GetPerformanceData()

Static i As Integer = FreshTime

LblCountdown.Text = i

If i = 0 Then
i = FreshTime
SetInactiveStatus()
Else
i -= 1
End If
End Sub


SetInactiveStatus code snippet:

While sdr.Read()
'Get the date'
Dim dateStr As String = sdr(1).ToString().Remove(0, 6)
myTime = DateTime.Parse(dateStr)
Dim dbDate = myTime.ToShortDateString()
Dim dbTime = myTime.TimeOfDay()
Dim dateToday = Now().Date
Dim timeToday = Now().TimeOfDay()

If dateToday = dbDate And timeToday > dbTime Then
'Add to array of inactive clusters'
inactive.AddRange({sdr(0), sdr(1)})
End If
End While
sdr.Close()


But the date comparison doesn't work if Now() is not uniform across the network. What can I use to make the entire network "act" like they are referring to the same date and time?

Appreciate any help.



Marilyn Gambone

Continue reading...
 
Back
Top