Imports System.Windows.Threading
Imports System.Collections.ObjectModel

Public Class ProcessManagerVM
   Inherits VMBase

   Private m_UpdateDataTimer As New DispatcherTimer

   Private m_ExecProcessManager As ExecProcessManager
   Public ReadOnly Property ExecProcessManager As ExecProcessManager
      Get
         Return m_ExecProcessManager
      End Get
   End Property

   Public ReadOnly Property ArgumentsQueue As String
      Get
         Return m_ExecProcessManager.ArgumentsQueueCount.ToString()
      End Get
   End Property

   Public ReadOnly Property ResultQueue As String
      Get
         Return m_ExecProcessManager.ArgumentsResultQueueCount.ToString()
      End Get
   End Property

   Public ReadOnly Property ThreadList As ObservableCollection(Of ThreadData)
      Get
         If Not IsNothing(m_ExecProcessManager.ThreadDataList) Then
            Return New ObservableCollection(Of ThreadData)(m_ExecProcessManager.ThreadDataList.ToList())
         Else
            Return New ObservableCollection(Of ThreadData)
         End If
      End Get
   End Property

   Sub New(ExecProcessManager As ExecProcessManager)
      m_ExecProcessManager = ExecProcessManager
      m_UpdateDataTimer.Interval = New TimeSpan(0, 0, 1)
      AddHandler m_UpdateDataTimer.Tick, AddressOf UpdateDataTimer_Tick
      m_UpdateDataTimer.Start()
   End Sub

   Private Sub UpdateDataTimer_Tick(sender As Object, e As EventArgs)
      NotifyPropertyChanged(NameOf(ArgumentsQueue))
      NotifyPropertyChanged(NameOf(ResultQueue))
      NotifyPropertyChanged(NameOf(ThreadList))
   End Sub

End Class

