/// <summary>
        /// Awake component.
        /// </summary>
        protected override void SingleAwake()
        {
            base.SingleAwake();

            CurrentState = NetworkUtility.GetNetworkConnectState();
            lastState    = CurrentState;
        }
 /// <summary>
 /// Update listener.
 /// </summary>
 private void Update()
 {
     CurrentState = NetworkUtility.GetNetworkConnectState();
     if (lastState != CurrentState)
     {
         lastState = CurrentState;
         OnStateChanged.Invoke(CurrentState);
     }
 }
        /// <summary>
        /// Turn on listener.
        /// </summary>
        public override void TurnOn()
        {
            //Thread can not restart after abort.
            if (refreshThread == null || !refreshThread.IsAlive)
            {
                base.TurnOn();

                refreshThread = ThreadUtility.RunAsync(() =>
                {
                    lastState = CurrentState = NetworkUtility.GetNetworkConnectState();
                    Thread.Sleep(RefreshCycle);

                    while (IsTurnOn)
                    {
                        CurrentState = NetworkUtility.GetNetworkConnectState();
                        Thread.Sleep(RefreshCycle);
                    }
                });
            }
        }
        /// <summary>
        /// Turn on listener.
        /// </summary>
        public void TurnOn()
        {
            //Thread can not restart after abort.
            if (refreshThread == null || !refreshThread.IsAlive)
            {
                refreshThread = new Thread(() =>
                {
                    lastState = CurrentState = NetworkUtility.GetNetworkConnectState();
                    Thread.Sleep(RefreshRate);

                    while (true)
                    {
                        CurrentState = NetworkUtility.GetNetworkConnectState();
                        Thread.Sleep(RefreshRate);
                    }
                })
                {
                    IsBackground = true
                };

                refreshThread.Start();
            }
            enabled = true;
        }