Пример #1
0
        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (_singletonChecker != null)
                    {
                        _singletonChecker.Dispose();
                        _singletonChecker = null;
                    }
                }

                _disposed = true;
            }
        }
Пример #2
0
        /// <summary>
        /// 检查系统的配置正确性
        /// </summary>
        public void Check()
        {
            var exeFullPathName = Assembly.GetEntryAssembly().Location;

            // 禁止从网络路径启动。
            if (!this.IsLocalDriver(exeFullPathName))
            {
                throw new Exception("禁止从网络路径启动程序!");
            }

            // 单实例检查
            _singletonChecker = new SingletonProcessChecker(exeFullPathName.Replace('\\', '_'));
            if (!_singletonChecker.IsPassed)
            {
                throw new Exception("程序的一个实例已经在运行。");
            }
        }