Exemplo n.º 1
0
        /// <summary>
        /// ctor which needs the appcast url and a referenceassembly
        /// </summary>
        /// <param name="appcastUrl">the URL for the appcast file</param>
        /// <param name="referenceAssembly">the reference assembly</param>
        /// <param name="showDiagnostic">show the diagnostics window.</param>
        public Sparkle(String appcastUrl, String referenceAssembly, bool showDiagnostic)
        {
            // preconfige ssl trust
            TrustEverySSLConnection = false;

            // configure ssl cert link
            ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidation;

            // enable visual style to ensure that we have XP style or higher
            // also in WPF applications
            System.Windows.Forms.Application.EnableVisualStyles();

            // reset vars
            ApplicationIcon       = null;
            _AppReferenceAssembly = null;

            // set var
            this.ShowDiagnosticWindow = showDiagnostic;
            _diagnostic = new NetSparkleDiagnostic(showDiagnostic);

            // set the reference assembly
            if (referenceAssembly != null)
            {
                _AppReferenceAssembly = referenceAssembly;
                _diagnostic.Report("Checking the following file: " + _AppReferenceAssembly);
            }

            // show if needed
            ShowDiagnosticWindowIfNeeded();

            // adjust the delegates
            _worker.WorkerReportsProgress = true;
            _worker.DoWork          += new DoWorkEventHandler(OnWorkerDoWork);
            _worker.ProgressChanged += new ProgressChangedEventHandler(OnWorkerProgressChanged);

            // build the wait handle
            _exitHandle    = new EventWaitHandle(false, EventResetMode.AutoReset);
            _loopingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            // set the url
            _AppCastUrl = appcastUrl;
            _diagnostic.Report("Using the following url: " + _AppCastUrl);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The method starts a NetSparkle background loop
        /// If NetSparkle is configured to check for updates on startup, proceeds to perform
        /// the check. You should only call this function when your app is initialized and
        /// shows its main window.
        /// </summary>
        /// <param name="doInitialCheck"><c>true</c> if this instance should do an initial check.</param>
        /// <param name="forceInitialCheck"><c>true</c> if this instance should force an initial check.</param>
        /// <param name="checkFrequency">the frequency between checks.</param>
        public void StartLoop(Boolean doInitialCheck, Boolean forceInitialCheck, TimeSpan checkFrequency)
        {
            // first set the event handle
            _loopingHandle.Set();

            // Start the helper thread as a background worker to
            // get well ui interaction

            // show if needed
            ShowDiagnosticWindowIfNeeded();

            // store infos
            _DoInitialCheck    = doInitialCheck;
            _ForceInitialCheck = forceInitialCheck;
            _CheckFrequency    = checkFrequency;

            // create and configure the worker
            _diagnostic.Report("Starting background worker");

            // start the work
            _worker.RunWorkerAsync();
        }
Exemplo n.º 3
0
        /// <summary>
        /// ctor which needs the appcast url and a referenceassembly
        /// </summary>        
        /// <param name="appcastUrl">the URL for the appcast file</param>
        /// <param name="referenceAssembly">the reference assembly</param>
        /// <param name="showDiagnostic">show the diagnostics window.</param>
        public Sparkle(String appcastUrl, String referenceAssembly, bool showDiagnostic)
        {
            // preconfige ssl trust
            TrustEverySSLConnection = false;

            // configure ssl cert link
            ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidation;

            // enable visual style to ensure that we have XP style or higher
            // also in WPF applications
            System.Windows.Forms.Application.EnableVisualStyles();

            // reset vars
            ApplicationIcon = null;
            _AppReferenceAssembly = null;

            // set var
            this.ShowDiagnosticWindow = showDiagnostic;
            _diagnostic = new NetSparkleDiagnostic(showDiagnostic);

            // set the reference assembly
            if (referenceAssembly != null)
            {
                _AppReferenceAssembly = referenceAssembly;
                _diagnostic.Report("Checking the following file: " + _AppReferenceAssembly);
            }

            // show if needed
            ShowDiagnosticWindowIfNeeded();

            // adjust the delegates
            _worker.WorkerReportsProgress = true;
            _worker.DoWork += new DoWorkEventHandler(OnWorkerDoWork);
            _worker.ProgressChanged += new ProgressChangedEventHandler(OnWorkerProgressChanged);

            // build the wait handle
            _exitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
            _loopingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            // set the url
            _AppCastUrl = appcastUrl;
            _diagnostic.Report("Using the following url: " + _AppCastUrl);
        }