PocketPC - Synchronize

PocketPC - Synchronize

The sample asks a time server for time and uses the answer to update time on the local machine.

C#

// initialize the Ntp object
Ntp client = new Ntp(serverName.Text);

// get the time difference
NtpResponse response = client.GetTime();

// show the time difference
timeDiff.Text = response.TimeOffset.ToTimeSpan().ToString();

// adjust the local clock
SystemClock.AdjustClock(response);

VB.NET

' initialize the Ntp object
Dim client As Ntp = New Ntp(serverName.Text)
' get the time difference
Dim response As NtpResponse = client.GetTime()

' show the time difference
timeDiff.Text = response.TimeOffset.ToTimeSpan().ToString()

' adjust the local clock
SystemClock.AdjustClock(response)

Included in

See also: