예제 #1
0
        /// <summary>
        /// Add the Main Form thread to the thread list and start it
        /// </summary>
        public void StartMainWindowThread()
        {
            if (_mainFormThread != null)
            {
                return;
            }

            _logger.Debug("Starting main form thread");

            var t = new SynchronizedThread(() =>
            {
                try
                {
                    MainWindow.ShowDialogTopMost();
                    _mainFormThread = null;
                }
                catch (Exception ex) { _logger.Error(ex); }
            });

            _mainFormThread      = t;
            _mainFormThread.Name = "MainFormThread";
            _mainFormThread.SetApartmentState(ApartmentState.STA);

            StartSynchronizedThread(t);
        }
예제 #2
0
        /// <summary>
        ///     Initialize with NextUpdate and UpdateInterval from Settings
        /// </summary>
        /// <summary>
        ///     Launch UpdateProcedure in separate Thread.
        ///     UpdateManager must be initialized!
        ///     Downloads update-info.txt and compares the recent (online) version to the current version
        ///     and launches assigned events.
        ///     Specific Events must be set in advance.
        ///     Can only be launched once at the time, reported in UpdateProcedureIsRunning flag.
        ///     Resets the UpdateManager afterwards.
        /// </summary>
        /// <param name="checkNecessity"></param>
        public void UpdateProcedure(bool checkNecessity)
        {
            var thread = new SynchronizedThread(() => UpdateThread(checkNecessity));

            thread.Name = "UpdateThread";
            thread.SetApartmentState(ApartmentState.STA);
            _threadManager.StartSynchronizedThread(thread);
        }
예제 #3
0
        /// <summary>
        ///     Show something to the user (if desired) while the conversion is going on
        /// </summary>
        protected virtual void ShowConversionProgress()
        {
            var progressWindowThread = new SynchronizedThread(ShowConversionProgressDialog);

            progressWindowThread.SetApartmentState(ApartmentState.STA);

            progressWindowThread.Name = "ProgressForm";

            ThreadManager.Instance.StartSynchronizedThread(progressWindowThread);
        }
예제 #4
0
        /// <summary>
        /// Initialize with NextUpdate and UpdateInterval from Settings
        /// </summary>
        /// <param name="settings">Current PdfCreatorSettings</param>
        /// <param name="gpoSettings">Current GpoSettings</param>
        //public void Initialize(PdfCreatorSettings settings, GpoSettings gpoSettings)
        //{
        //    Initialize(settings.ApplicationSettings, settings.ApplicationProperties, gpoSettings);
        //}

        /// <summary>
        /// Launch UpdateProcedure in separate Thread.
        /// UpdateManager must be initialized!
        /// Downloads update-info.txt and compares the recent (online) version to the current version
        /// and launches assigned events.
        /// Specific Events must be set in advance.
        /// Can only be launched once at the time, reported in UpdateProcedureIsRunning flag.
        /// Resets the UpdateManager afterwards.
        /// </summary>
        /// <param name="checkNecessity"></param>
        public void UpdateProcedure(bool checkNecessity)
        {
            _checkNecessity = checkNecessity;

            var thread = new SynchronizedThread(UpdateThread);

            thread.Name = "UpdateThread";
            thread.SetApartmentState(ApartmentState.STA);
            ThreadManager.Instance.StartSynchronizedThread(thread);
        }
예제 #5
0
        /// <summary>
        ///     Initialize with NextUpdate and UpdateInterval from Settings
        /// </summary>
        /// <summary>
        ///     Launch UpdateProcedure in separate Thread.
        ///     UpdateManager must be initialized!
        ///     Downloads update-info.txt and compares the recent (online) version to the current version
        ///     and launches assigned events.
        ///     Specific Events must be set in advance.
        ///     Can only be launched once at the time, reported in UpdateProcedureIsRunning flag.
        ///     Resets the UpdateManager afterwards.
        /// </summary>
        /// <param name="checkNecessity"></param>
        /// <param name="onlyNotifyOnNewUpdate">When true, a message is only displayed to the user, if an update is available. Otherwise, a message will be displayed that no update is available</param>
        public void UpdateProcedure(bool checkNecessity, bool onlyNotifyOnNewUpdate)
        {
            _checkNecessity = checkNecessity;

            var thread = new SynchronizedThread(() => UpdateThread(onlyNotifyOnNewUpdate));

            thread.Name = "UpdateThread";
            thread.SetApartmentState(ApartmentState.STA);
            _threadManager.StartSynchronizedThread(thread);
        }
        public void SendUsageStatistics(TimeSpan duration, Job job, string status)
        {
            if (IsEnabled)
            {
                var usageMetric = CreateJobUsageStatisticsMetric(job, duration, status);

                var senderThread = new SynchronizedThread(() => _sender.Send(usageMetric));

                _threadManager.StartSynchronizedThread(senderThread);
            }
        }
예제 #7
0
        protected override bool StartApplication()
        {
            _logger.Debug("Starting main window");
            _mainWindowThreadLauncher.LaunchMainWindow();

            var pdfArchitectCheckThread = new SynchronizedThread(() => { _pdfArchitectCheck.IsInstalled(); });

            _threadManager.StartSynchronizedThread(pdfArchitectCheckThread);

            return(true);
        }
예제 #8
0
        public static void ShowTopMost(int currentCount)
        {
            CurrentCount = currentCount;
            var thread = new SynchronizedThread(ShowPlusHintWindow)
            {
                Name = "PlusHintThread"
            };

            thread.SetApartmentState(ApartmentState.STA);

            ThreadManager.Instance.StartSynchronizedThread(thread);
        }
예제 #9
0
        /// <summary>
        ///     Starts a new asynchronous thread
        /// </summary>
        private void CreateThread(string filename)
        {
            Logger.Trace("COM: Removing jobinfo from queue.");
            _jobInfoQueue.Remove(Job.JobInfo);

            Logger.Trace("COM: Creating new asynchronous thread.");
            var thread = new SynchronizedThread(() => DoConversion(Job, filename));

            thread.Name = "ConversionThread";

            Logger.Trace("COM: Adding the new thread to the thread pool.");
            _threadPool.AddThread(thread);
        }
        public void Show(Job job)
        {
            if (!job.Profile.ShowProgress)
            {
                return;
            }

            var progressWindowThread = new SynchronizedThread(() => ShowConversionProgressDialog(job));

            progressWindowThread.SetApartmentState(ApartmentState.STA);

            progressWindowThread.Name = "ProgressForm";

            _threadManager.StartSynchronizedThread(progressWindowThread);
        }
예제 #11
0
        /// <summary>
        /// Add the clean up thread to the thread list and start it.
        /// The thread will look for outdated temporary files and will delete them
        /// </summary>
        public void StartCleanUpThread()
        {
            if (_cleanUpThread != null)
            {
                return;
            }

            _logger.Debug("Starting cleanup");

            var t = new SynchronizedThread(() => { JobInfoQueue.Instance.CleanTempFiles(); _cleanUpThread = null; });

            _cleanUpThread      = t;
            _cleanUpThread.Name = "CleanUpThread";

            StartSynchronizedThread(t);
        }
예제 #12
0
        /// <summary>
        /// Starts a new asynchronous thread
        /// </summary>
        private void CreateThread()
        {
            Logger.Trace("COM: Removing jobinfo from queue.");
            _comJobInfoQueue.Remove(JobInfo);

            Logger.Trace("COM: Creating new asynchronous thread.");
            var aThread = new SynchronizedThread(DoConversion);

            aThread.OnThreadFinished += (sender, args) =>
            {
                if (OnJobFinished != null)
                {
                    OnJobFinished(aThread, args);
                }
            };
            aThread.Name = "ConversionThread";

            Logger.Trace("COM: Adding the new thread to the thread pool.");
            _threadPool.AddThread(aThread);
        }