示例#1
0
 /// <summary>
 /// Raises the <seealso cref="TimeReceived"/> event.
 /// </summary>
 /// <remarks>
 /// <para>This event may be raised on a different thread than called the <see cref="BeginRequestTime"/> method. If the event handler refers to UI, COM or other components that require thread affinity then dispatched invoke may be required.</para>
 /// <para>The time returned is a UTC time.</para>
 /// </remarks>
 /// <param name="ntpTime">The date and time received from the NTP server.</param>
 /// <param name="receivedAt">The (UTC) date and time of the system upon reception.</param>
 /// <seealso cref="TimeReceived"/>
 protected void OnTimeReceived(DateTime ntpTime, DateTime receivedAt)
 {
     ExecuteWithSuppressedExceptions(() =>
     {
         TimeReceived?.Invoke(this, new NtpTimeReceivedEventArgs(ntpTime, receivedAt));
     });
 }
示例#2
0
        public byte[] ToByteArray()
        {
            List <byte> byteList = new List <byte>();

            byteList.AddRange(Encoding.UTF8.GetBytes(Sender));
            byteList.Add(PackageControl.UnitSeperator);
            byteList.AddRange(Encoding.UTF8.GetBytes(Receiver));
            byteList.Add(PackageControl.UnitSeperator);
            byteList.AddRange(Encoding.UTF8.GetBytes(TimeReceived.ToString()));
            byteList.Add(PackageControl.UnitSeperator);
            byteList.AddRange(Encoding.UTF8.GetBytes(Text));
            byteList.Add(PackageControl.GroupSeperator);

            return(byteList.ToArray());
        }