Example #1
0
        static public IDisposable Initialize(CKAppParameters app)
        {
            if (_params != null)
            {
                throw new InvalidOperationException("initonce");
            }
            _params = app;

            // This is the mutex used as a flag for installer.
            // Since it is "Global\", it is shared among multiple terminal services client.
            // We keep a reference on it. It will be released at the end of the process.
            Mutex mutextForInstaller = new Mutex(false, _params.GlobalMutexName);
            // This unique Application key is "local": it is not shared among terminal server connections.
            bool  isNew;
            Mutex mutex = new Mutex(true, @"Local\" + _params.LocalMutexName, out isNew);

            if (!isNew)
            {
                mutex.Dispose();
                return(null);
            }
            Debug.Assert(_params.ApplicationDataPath.EndsWith(@"\"));

            // This call also initializes the CrashLogManager subsystem.
            AppRecoveryManager.Initialize(_params.ApplicationDataPath + @"CrashLogs\");
            try
            {
                // Here is where handling any existing CrashLogDirectory must be processed.
                // If the logs are sent (or are to be sent), this directory must no more exist otherwise the user will
                // be prompted again next time the application runs.
                CrashLogManager.HandleExistingCrashLogs();

                // Handle existing updates after crash logs: this way the crash mechanism
                // can be updated!
                UpdateManager.Initialize(_params.CommonApplicationDataPath, _params.ApplicationDataPath);
                if (!UpdateManager.LaunchExistingUpdater())
                {
                    mutex.Dispose();
                    return(null);
                }
                return(mutex);
            }
            catch (Exception ex)
            {
                CrashLogManager.CreateNew().WriteLineException(ex);
                mutex.Dispose();
                return(null);
            }
        }
 /// <summary>
 /// The SubAppName is the name of the package (Standard, Steria etc...)
 /// using that, we can have different contexts/userconfs for each packages installed on the computer.
 /// </summary>
 private CivikeyStandardHost( CKAppParameters parameters )
 {
     applicationParameters = parameters;
 }
        /// <summary>
        /// The SubAppName is the name of the package (Standard, Steria etc...)
        /// using that, we can have different contexts/userconfs for each packages installed on the computer.
        /// </summary>
        private CivikeyStandardHost( CKAppParameters parameters )
        {
            applicationParameters = parameters;

            ApplicationUniqueId = new SimpleUniqueId( App.ApplicationId );
        }