예제 #1
0
        /// <summary>
        /// Starts the asynchronous update process.
        /// </summary>
        /// <exception cref="InvalidOperationException"><see cref="IsRunning"/> was true.</exception>
        public void Start()
        {
            // Check the current IsRunning state, and set it to true
            bool isAlreadyRunning;

            lock (_isRunningSync)
            {
                isAlreadyRunning = IsRunning;
                if (!isAlreadyRunning)
                {
                    _isRunning = true;
                }
            }

            // Throw an exception if the IsRunning was already true
            if (isAlreadyRunning)
            {
                throw new InvalidOperationException("The UpdateClient is already running.");
            }

            try
            {
                if (IsRunningChanged != null)
                {
                    IsRunningChanged(this);
                }
            }
            catch (NullReferenceException ex)
            {
                Debug.Fail(ex.ToString());
            }

            State = UpdateClientState.Initializing;

            // Create the objects
            _msr          = new MasterServerReader(Settings.LocalFileServerPath, Settings.LocalMasterServerPath);
            _fileReplacer = Settings.CreateOfflineFileReplacer();

            State = UpdateClientState.ReadingLiveVersion;

            // Start grabbing from the master server
            _msr.BeginReadVersion(MasterServerReader_Callback, this);
        }
예제 #2
0
        /// <summary>
        /// Starts the asynchronous update process.
        /// </summary>
        /// <exception cref="InvalidOperationException"><see cref="IsRunning"/> was true.</exception>
        public void Start()
        {
            // Check the current IsRunning state, and set it to true
            bool isAlreadyRunning;
            lock (_isRunningSync)
            {
                isAlreadyRunning = IsRunning;
                if (!isAlreadyRunning)
                    _isRunning = true;
            }

            // Throw an exception if the IsRunning was already true
            if (isAlreadyRunning)
                throw new InvalidOperationException("The UpdateClient is already running.");

            try
            {
                if (IsRunningChanged != null)
                    IsRunningChanged(this);
            }
            catch (NullReferenceException ex)
            {
                Debug.Fail(ex.ToString());
            }

            State = UpdateClientState.Initializing;

            // Create the objects
            _msr = new MasterServerReader(Settings.LocalFileServerPath, Settings.LocalMasterServerPath);
            _fileReplacer = Settings.CreateOfflineFileReplacer();

            State = UpdateClientState.ReadingLiveVersion;

            // Start grabbing from the master server
            _msr.BeginReadVersion(MasterServerReader_Callback, this);
        }