25-10-17, 11:44 AM
السلام عليكم ورحمة الله وبركاته
حاولت إضافة دالة المعالج الخلفي إلا أنه ما زال يوجد تهنيج عند تنفيذ الكود
وهذا هو الكود الذي أقوم بتنفيذه:
PHP كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Task.Factory.StartNew(Sub()
'تاريخ النت
Dispatcher.BeginInvoke(Sub() GetDateNet = GetInternetTime("time.nist.gov", True))
End Sub)
End Sub
Public Function GetInternetTime(ByVal host As String, Optional ByVal ToLocalTime As Boolean = False) As DateTime
'الحصول على تاريخ النت
Dim timeStr As String
Dim reader As New IO.StreamReader(New Net.Sockets.TcpClient(host, 13).GetStream)
Dim LastSysTime As DateTime
LastSysTime = DateTime.UtcNow()
timeStr = reader.ReadToEnd
reader.Close()
Dim year As Integer = CInt(timeStr.Substring(7, 2)) + 2000
Dim month As Integer = CInt(timeStr.Substring(10, 2))
Dim day As Integer = CInt(timeStr.Substring(13, 2))
Dim hour As Integer = CInt(timeStr.Substring(16, 2))
Dim minute As Integer = CInt(timeStr.Substring(19, 2))
Dim second As Integer = CInt(timeStr.Substring(22, 2))
If ToLocalTime Then
Return New DateTime(year, month, day, hour, minute, second).ToLocalTime
Else
Return New DateTime(year, month, day, hour, minute, second)
End If
End Function
فاعلم أنه لا إله إلا الله