Exemplo n.º 1
0
        /***********************************************************************************************************/


        #region ----- Private Methods ------


        /// <summary>
        /// This will raise an event when there is a change in online status
        /// </summary>
        /// <param name="state"></param>
        private void CheckInternetConnection()
        {
            bool status;

            status = NetworkUtilities.GetOnlineStatus();

            // If the online status has changed notify the subscribers
            if ((status != _Status) || _IsFirstTime)
            {
                if (status)
                {
                    _ConnectionStatus = (int)CONNECTIONSTATE.ONLINE;
                    _IsOnline         = true;
                }
                else
                {
                    _ConnectionStatus = (int)CONNECTIONSTATE.OFFLINE;
                    _IsOnline         = false;
                }

                // Create the OnlineStatusEventArgs object to pass to the subscribers
                OnlineStatusEventArgs onlineStatusEvent = new OnlineStatusEventArgs(_ConnectionStatus);

                // If anyone has subscribed, notify them
                OnOnlineStatusChange(onlineStatusEvent);

                _IsFirstTime = false;
            }

            // update online status state
            _Status = status;
        }
Exemplo n.º 2
0
        /***********************************************************************************************************/


        #region ----- Protected Fire Event ------


        /// <summary>
        /// The method which fires the Event.
        /// </summary>
        /// <param name="onlineStatusEvent"></param>
        protected void OnOnlineStatusChange(OnlineStatusEventArgs onlineStatusEvent)
        {
            // Check if there are any Subscribers
            if (OnlineStatusChange != null)
            {
                // Call the Event
                OnlineStatusChange(onlineStatusEvent);
            }
        }