Imports System.Threading
Imports System.Data.OleDb
Public Class UpThread
    Private objThread As Thread
    Private ChkThread As Thread
    Private ipThread As Thread
    Dim Conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.AppDomain.CurrentDomain.BaseDirectory() & "progdb.mdb;")
    Dim SQL As OleDbCommand
    Dim RSet As OleDbDataReader



    Public Sub Update_IP()

        Dim objThreadStart As New ThreadStart(AddressOf IP_Update)
        objThread = New Thread(objThreadStart)
        objThread.Start()

    End Sub
    Public Sub IP_Update()

        Try
            Static TimeNow As String
            SQL = New OleDbCommand("select Hours, Minutes From Settings", Conn)
            Conn.Open()
            Do
                RSet = SQL.ExecuteReader
                If RSet.HasRows = False Then
                Else
                    While RSet.Read
                        Hours = RSet("Hours").ToString
                        Minutes = RSet("Minutes").ToString
                    End While
                    If TimeNow = "" Then
                        TimeNow = FormatDateTime(TimeOfDay, DateFormat.ShortTime)
                    End If
                    If Functions.CheckDaily(TimeNow) = True Then
                        Send_Updates()
                        TimeNow = FormatDateTime(TimeOfDay, DateFormat.ShortTime)
                    End If
                End If
                RSet.Close()
                Thread.Sleep(10000)
            Loop
            Conn.Close()
        Catch
            Functions.CreateError(Err.Description & " " & Err.Source, Err.Number)
        End Try

    End Sub
    Public Sub Dom_Sync()

        Try
            Do
                Functions.ReadDoms()
                Thread.Sleep(120000)
            Loop
        Catch
            Functions.CreateError(Err.Description & " " & Err.Source, Err.Number)
        End Try

    End Sub
    Public Sub Detection_Sync()

        Try
            Do
                Functions.Maintain_IP_Detect()
                Thread.Sleep(60000)
            Loop
        Catch
            Functions.CreateError(Err.Description & " " & Err.Source, Err.Number)
        End Try

    End Sub
    Public Sub Chk_up()

        Dim ChkThread_Start As New ThreadStart(AddressOf Me.Dom_Sync)
        ChkThread = New Thread(ChkThread_Start)
        ChkThread.Start()

    End Sub
    Public Sub IP_up()

        Dim ChkThread_Start As New ThreadStart(AddressOf Me.Detection_Sync)
        ipThread = New Thread(ChkThread_Start)
        ipThread.Start()

    End Sub

End Class
