コード例 #1
0
        /// <summary>
        ///     Downloads the pdbs from the symbol server.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="symbolServer">The symbol server name.</param>
        /// <param name="downloadDir">The download directory. Can be null.</param>
        /// <returns>
        ///     true if all symbols could be downloaded. False otherwise.
        /// </returns>
        public bool DownloadPdbs(FileQuery query, string symbolServer, string downloadDir)
        {
            using (var t = new Tracer(myType, "DownloadPdbs"))
            {
                var lret             = SymChkExecutor.bCanStartSymChk;
                var currentFailCount = this.FailedPdbs.Count;

                var fileQueue  = query.EnumerateFiles;
                var aggregator = new BlockingQueueAggregator <string>(fileQueue);

                Action <string> downLoadPdbThread = (string fileName) =>
                {
                    var pdbFileName = GetPdbNameFromBinaryName(fileName);

                    // delete old pdb to ensure that the new matching pdb is really downloaded. Symchk does not replace existing but not matching pdbs.
                    try
                    {
                        File.Delete(pdbFileName);
                    }
                    catch
                    {
                    }

                    if (!this.Executor.DownLoadPdb(fileName, symbolServer, downloadDir))
                    {
                        lock (this.FailedPdbs)
                        {
                            this.FailedPdbs.Add(Path.GetFileName(fileName));
                        }
                    }
                    else
                    {
                        lock (this.FailedPdbs)
                        {
                            this.SucceededPdbCount++;
                        }
                    }
                };

                var dispatcher = new WorkItemDispatcher <string>(this.myDownLoadThreadCount, downLoadPdbThread, "Pdb Downloader", aggregator, WorkItemOptions.AggregateExceptions);

                try
                {
                    dispatcher.Dispose();
                }
                catch (AggregateException ex)
                {
                    t.Error(ex, "Got error during pdb download");
                    lret = false;
                }

                if (this.FailedPdbs.Count > currentFailCount)
                {
                    t.Warning("The failed pdb count has increased by {0}", this.FailedPdbs.Count - currentFailCount);
                    lret = false;
                }

                return(lret);
            }
        }
コード例 #2
0
        public void ThrowException_On_Enqueue_WhenWorker_Has_Faulted()
        {
            bool bCalled = false;
            BlockingQueue <string> work = new BlockingQueue <string>();

            WorkItemDispatcher <string> dispatcher = new WorkItemDispatcher <string>(
                5, // work in 5 threads
                (data) =>
            {
                try
                {
                    throw new Exception(ExceptionMessage);
                }
                finally
                {
                    bCalled = true;
                }
            },
                work
                );

            work.Enqueue("some work");
            work.ReleaseWaiters();

            while (!bCalled)
            {
                Thread.Sleep(10);
            }
            Thread.Sleep(10);

            Assert.Throws <AggregateException>(() => dispatcher.Dispose());
        }
コード例 #3
0
        public void Enqueue_Work_Without_WaitingForCompletion()
        {
            int count = 0;
            int Runs  = 100;

            for (int k = 0; k < Runs; k++)
            {
                BlockingQueue <string> work = new BlockingQueue <string>();

                WorkItemDispatcher <string> dispatcher = new WorkItemDispatcher <string>(
                    2,                                          // work in 2 threads
                    (data) => Interlocked.Increment(ref count), // increment counter for each work item
                    work
                    );

                for (int i = 0; i < Runs; i++)
                {
                    work.Enqueue("Hello");
                }
                work.Enqueue(null);
            }

            for (int i = 0; i < 10; i++)
            {
                if (count == Runs * Runs)
                {
                    break;
                }

                Thread.Sleep(100);
            }

            Assert.AreEqual(Runs * Runs, count, "All work items should be processed even when we do not wait for completion.");
        }
コード例 #4
0
        public void Do_Not_Mask_Exceptions_When_Disposing()
        {
            Assert.Throws <DataMisalignedException>(() =>
            {
                bool bCalled = false;
                BlockingQueue <string> work = new BlockingQueue <string>();

                using (WorkItemDispatcher <string> dispatcher = new WorkItemDispatcher <string>(
                           5, // work in 5 threads
                           (data) =>
                {
                    bCalled = true;
                    throw new Exception(ExceptionMessage);
                },
                           work
                           ))
                {
                    work.Enqueue("some work");
                    while (!bCalled)
                    {
                        Thread.Sleep(10);
                    }
                    work.ReleaseWaiters();
                    throw new DataMisalignedException("Some other exception");
                }
            });
        }
コード例 #5
0
ファイル: CommandBase.cs プロジェクト: arlm/apichange
        protected void GetFilesFromQueryMultiThreaded(List <FileQuery> fileQueries, Action <string> fileOperator)
        {
            BlockingQueue <string> [] queues = (from query in fileQueries
                                                select query.EnumerateFiles).ToArray();

            BlockingQueueAggregator <string> aggregator = new BlockingQueueAggregator <string>(queues);

            var dispatcher = new WorkItemDispatcher <string>(myParsedArgs.ThreadCount, fileOperator, "File Loader", aggregator, WorkItemOptions.AggregateExceptions);

            // Wait until work is done
            dispatcher.Dispose();
        }
コード例 #6
0
        public EffectRendererWorkItemQueue(WorkItemDispatcher dispatcher, WorkItemQueuePriority priority, int maxThreadCount) : base(dispatcher, priority)
        {
            this.sync           = new object();
            this.maxThreadCount = maxThreadCount;
            this.queue          = new ConcurrentQueue <Action>();
            this.idleEvent      = new ManualResetEvent(true);
            MultithreadedWorkItemDispatcher dispatcher2 = dispatcher as MultithreadedWorkItemDispatcher;

            if (dispatcher2 != null)
            {
                this.threadCountToken = dispatcher2.UseThreadCount(maxThreadCount);
            }
        }
コード例 #7
0
        public void RethrowException_On_Dispose_By_Default()
        {
            BlockingQueue <string>      work       = new BlockingQueue <string>();
            WorkItemDispatcher <string> dispatcher = new WorkItemDispatcher <string>(
                5, // work in 5 threads
                (data) =>
            {
                throw new Exception(ExceptionMessage);
            },
                work
                );

            work.Enqueue("some work");
            work.ReleaseWaiters();

            Assert.Throws <AggregateException>(() => dispatcher.Dispose());
        }
コード例 #8
0
        public void Do_Not_Throw_On_Enqueue_When_Aggregating()
        {
            int called = 0;

            BlockingQueue <string>      work       = new BlockingQueue <string>();
            WorkItemDispatcher <string> dispatcher = new WorkItemDispatcher <string>(
                5, // work in 5 threads
                (data) =>
            {
                Interlocked.Increment(ref called);
                throw new Exception(ExceptionMessage);
            },
                work,
                WorkItemOptions.AggregateExceptions
                );

            work.Enqueue("some work");

            while (called == 0)
            {
                Thread.Sleep(10);
            }

            for (int i = 0; i < 100; i++)
            {
                work.Enqueue("other work");
            }

            work.ReleaseWaiters();

            try
            {
                dispatcher.Dispose();
            }
            catch (AggregateException ex)
            {
                Assert.AreEqual(101, ex.InnerExceptions.Count);
            }
        }
コード例 #9
0
        public void Can_Use_WorkItemDispatcher_On_STA_Thread()
        {
            Exception cex = null;
            Thread    t   = new Thread(() =>
            {
                try
                {
                    var queue = new BlockingQueue <string>();

                    int processed  = 0;
                    var dispatcher = new WorkItemDispatcher <string>(5,
                                                                     (workstring) =>
                    {
                        Interlocked.Increment(ref processed);
                    },
                                                                     "Tester", queue);

                    queue.Enqueue("Work1");
                    queue.Enqueue("Work2");
                    queue.ReleaseWaiters();

                    dispatcher.Dispose();
                }
                catch (Exception ex)
                {
                    cex = ex;
                }
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();

            if (cex != null)
            {
                Assert.Fail("Get Exception On STA Thread: " + cex);
            }
        }
コード例 #10
0
 public DocumentCanvasTileCache(DocumentCanvasLayer owner, IBitmapSource <ColorBgra32> source, int sourceTileEdgeLog2, int mipLevel, bool highQuality)
 {
     Validate.Begin().IsNotNull <DocumentCanvasLayer>(owner, "owner").IsNotNull <IBitmapSource <ColorBgra32> >(source, "source").Check();
     if (sourceTileEdgeLog2 < 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("sourceTileEdgeLog2");
     }
     if (mipLevel < 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("mipLevel");
     }
     this.syncContext        = SynchronizationContext.Current;
     this.owner              = owner;
     this.source             = source;
     this.sourceSize         = this.source.Size;
     this.sourceBounds       = this.source.Bounds();
     this.isHighQuality      = highQuality;
     this.tileMathHelper     = new PaintDotNet.Rendering.TileMathHelper(this.sourceSize.Width, this.sourceSize.Height, sourceTileEdgeLog2);
     this.mipLevel           = mipLevel;
     this.tileIsValid        = ArrayUtil.Create2D <bool>(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns);
     this.invalidTileOffsets = new DequeSet <PointInt32>();
     this.tileBuffers        = ArrayUtil.Create2D <IBitmap <ColorPbgra32> >(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns);
     for (int i = 0; i < this.tileMathHelper.TileRows; i++)
     {
         for (int j = 0; j < this.tileMathHelper.TileColumns; j++)
         {
             this.invalidTileOffsets.TryEnqueue(new PointInt32(j, i));
         }
     }
     this.tilesRenderQueue                 = new DequeSet <PointInt32>();
     this.tilesRenderingSet                = new HashSet <PointInt32>();
     this.tilesRenderingCancelledSet       = new ConcurrentSet <PointInt32>();
     this.tilesRenderedQueue               = new ConcurrentDequeDictionary <PointInt32, RenderedTileInfo>();
     this.processTileRenderQueueCallback   = new SendOrPostCallback(this.ProcessTileRenderQueueCallback);
     this.processTileRenderedQueueCallback = new SendOrPostCallback(this.ProcessTileRenderedQueueCallback);
     this.workItemDispatcher               = WorkItemDispatcher.Default;
     this.workItemQueue = new EditableDataWorkItemQueue <PointInt32>(this.workItemDispatcher, new Action <PointInt32>(this.RenderTileWorkItem));
 }
コード例 #11
0
        public void Can_Process_List_Of_Queues()
        {
            var q1     = new BlockingQueue <string>();
            var q2     = new BlockingQueue <string>();
            var q3     = new BlockingQueue <string>();
            var queues = new BlockingQueue <string>[] { q1, q2, q3 };

            var agg = new BlockingQueueAggregator <string>(queues);

            int processed  = 0;
            var dispatcher = new WorkItemDispatcher <string>(5,
                                                             (workstring) =>
            {
                Interlocked.Increment(ref processed);
            },
                                                             "Tester", agg);

            const int Runs = 10;

            for (int i = 0; i < Runs; i++)
            {
                for (int k = 0; k < queues.Length; k++)
                {
                    queues[k].Enqueue("q" + k.ToString() + "_" + i.ToString());
                }
            }

            // signal end of each queue
            q1.Enqueue(null);
            q2.Enqueue(null);
            q3.Enqueue(null);

            dispatcher.Dispose();

            Assert.AreEqual(Runs * queues.Length, processed);
        }
コード例 #12
0
        ///// <summary>
        ///// Count Test Cases using a filter
        ///// </summary>
        ///// <param name="filter">The filter to apply</param>
        ///// <returns>The number of test cases found</returns>
        //public int CountTestCases(TestFilter filter)
        //{
        //    return this.suite.CountTestCases(filter);
        //}

        /// <summary>
        /// Run selected tests and return a test result. The test is run synchronously,
        /// and the listener interface is notified as it progresses.
        /// </summary>
        /// <param name="listener">Interface to receive EventListener notifications.</param>
        /// <param name="filter">A test filter used to select tests to be run</param>
        /// <returns></returns>
        public ITestResult Run(ITestListener listener, ITestFilter filter)
        {
            log.Info("Running tests");
            if (_loadedTest == null)
            {
                throw new InvalidOperationException("Run was called but no test has been loaded.");
            }

            // Save Console.Out and Error for later restoration
            TextWriter savedOut = Console.Out;
            TextWriter savedErr = Console.Error;

            TestExecutionContext initialContext = CreateTestExecutionContext(_settings);

#if NUNITLITE
            initialContext.Listener = listener;

            WorkItem workItem = WorkItem.CreateWorkItem(_loadedTest, initialContext, filter);
            workItem.Completed += new EventHandler(OnRunCompleted);
            workItem.Execute();

            _runComplete.WaitOne();

            return(workItem.Result);
#else
            QueuingEventListener queue = new QueuingEventListener();

            if (_settings.Contains("CaptureStandardOutput"))
            {
                initialContext.Out = new EventListenerTextWriter(queue, TestOutputType.Out);
            }
            if (_settings.Contains("CapureStandardError"))
            {
                initialContext.Error = new EventListenerTextWriter(queue, TestOutputType.Error);
            }

            initialContext.Listener = queue;

            int numWorkers = _settings.Contains("NumberOfTestWorkers")
                ? (int)_settings["NumberOfTestWorkers"]
                : 0;

            WorkItemDispatcher dispatcher = null;

            if (numWorkers > 0)
            {
                dispatcher = new WorkItemDispatcher(numWorkers);
                initialContext.Dispatcher = dispatcher;
            }

            WorkItem workItem = WorkItem.CreateWorkItem(_loadedTest, initialContext, filter);
            workItem.Completed += new EventHandler(OnRunCompleted);

            using (EventPump pump = new EventPump(listener, queue.Events))
            {
                pump.Start();

                if (dispatcher != null)
                {
                    dispatcher.Dispatch(workItem);
                    dispatcher.Start();
                }
                else
                {
                    workItem.Execute();
                }

                _runComplete.WaitOne();
            }

            Console.SetOut(savedOut);
            Console.SetError(savedErr);

            if (dispatcher != null)
            {
                dispatcher.Stop();
                dispatcher = null;
            }

            return(workItem.Result);
#endif
        }
コード例 #13
0
        /// <summary>
        /// Run selected tests and return a test result. The test is run synchronously,
        /// and the listener interface is notified as it progresses.
        /// </summary>
        /// <param name="listener">Interface to receive EventListener notifications.</param>
        /// <param name="filter">A test filter used to select tests to be run</param>
        /// <returns></returns>
        public ITestResult Run(ITestListener listener, ITestFilter filter)
        {
            log.Info("Running tests");
            if (_loadedTest == null)
            {
                throw new InvalidOperationException("Run was called but no test has been loaded.");
            }

            // Save Console.Out and Error for later restoration
            TextWriter savedOut = Console.Out;
            TextWriter savedErr = Console.Error;

            TestExecutionContext initialContext = CreateTestExecutionContext(_settings);

#if NUNITLITE
            initialContext.Listener = listener;

            WorkItem workItem = WorkItem.CreateWorkItem(_loadedTest, initialContext, filter);
            workItem.Completed += new EventHandler(OnRunCompleted);
            workItem.Execute();

            _runComplete.WaitOne();

            return(workItem.Result);
#else
            QueuingEventListener queue = new QueuingEventListener();

            if (_settings.Contains("CaptureStandardOutput"))
            {
                initialContext.Out = new EventListenerTextWriter(queue, TestOutputType.Out);
            }
            if (_settings.Contains("CapureStandardError"))
            {
                initialContext.Error = new EventListenerTextWriter(queue, TestOutputType.Error);
            }

            initialContext.Listener = queue;

            int levelOfParallelization = _settings.Contains("NumberOfTestWorkers")
                ? (int)_settings["NumberOfTestWorkers"]
                : _loadedTest.Properties.ContainsKey(PropertyNames.LevelOfParallelization)
                    ? (int)_loadedTest.Properties.Get(PropertyNames.LevelOfParallelization)
                    : Math.Max(Environment.ProcessorCount, 2);

            WorkItemDispatcher dispatcher = null;

            if (levelOfParallelization > 0)
            {
                dispatcher = new WorkItemDispatcher(levelOfParallelization);
                initialContext.Dispatcher = dispatcher;
                // Assembly does not have IApplyToContext attributes applied
                // when the test is built, so  we do it here.
                // TODO: Generalize this
                if (_loadedTest.Properties.ContainsKey(PropertyNames.ParallelScope))
                {
                    initialContext.ParallelScope =
                        (ParallelScope)_loadedTest.Properties.Get(PropertyNames.ParallelScope) & ~ParallelScope.Self;
                }
            }

            WorkItem workItem = WorkItem.CreateWorkItem(_loadedTest, initialContext, filter);
            workItem.Completed += new EventHandler(OnRunCompleted);

            using (EventPump pump = new EventPump(listener, queue.Events))
            {
                pump.Start();

                if (dispatcher != null)
                {
                    dispatcher.Dispatch(workItem);
                    dispatcher.Start();
                }
                else
                {
                    workItem.Execute();
                }

                _runComplete.WaitOne();
            }

            Console.SetOut(savedOut);
            Console.SetError(savedErr);

            if (dispatcher != null)
            {
                dispatcher.Stop();
                dispatcher = null;
            }

            return(workItem.Result);
#endif
        }
コード例 #14
0
        /// <summary>
        ///     Downloads the pdbs from the symbol server.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="symbolServer">The symbol server name.</param>
        /// <param name="downloadDir">The download directory. Can be null.</param>
        /// <returns>
        ///     true if all symbols could be downloaded. False otherwise.
        /// </returns>
        public bool DownloadPdbs(FileQuery query, string symbolServer, string downloadDir)
        {
            using (var t = new Tracer(myType, "DownloadPdbs"))
            {
                var lret = SymChkExecutor.bCanStartSymChk;
                var currentFailCount = this.FailedPdbs.Count;

                var fileQueue = query.EnumerateFiles;
                var aggregator = new BlockingQueueAggregator<string>(fileQueue);

                Action<string> downLoadPdbThread = (string fileName) =>
                {
                    var pdbFileName = GetPdbNameFromBinaryName(fileName);

                    // delete old pdb to ensure that the new matching pdb is really downloaded. Symchk does not replace existing but not matching pdbs.
                    try
                    {
                        File.Delete(pdbFileName);
                    }
                    catch
                    {
                    }

                    if (!this.Executor.DownLoadPdb(fileName, symbolServer, downloadDir))
                    {
                        lock (this.FailedPdbs)
                        {
                            this.FailedPdbs.Add(Path.GetFileName(fileName));
                        }
                    }
                    else
                    {
                        lock (this.FailedPdbs)
                        {
                            this.SucceededPdbCount++;
                        }
                    }
                };

                var dispatcher = new WorkItemDispatcher<string>(this.myDownLoadThreadCount, downLoadPdbThread, "Pdb Downloader", aggregator, WorkItemOptions.AggregateExceptions);

                try
                {
                    dispatcher.Dispose();
                }
                catch (AggregateException ex)
                {
                    t.Error(ex, "Got error during pdb download");
                    lret = false;
                }

                if (this.FailedPdbs.Count > currentFailCount)
                {
                    t.Warning("The failed pdb count has increased by {0}", this.FailedPdbs.Count - currentFailCount);
                    lret = false;
                }

                return lret;
            }
        }
コード例 #15
0
ファイル: Startup.cs プロジェクト: ykafia/Paint.Net4
        private void StartPart2(string mutexName, string[] remainingArgs)
        {
            IAnimationService animationService;

            Memory.Initialize();
            CultureInfo info = AppSettings.Instance.UI.Language.Value;

            Thread.CurrentThread.CurrentUICulture     = info;
            CultureInfo.DefaultThreadCurrentUICulture = info;
            AppSettings.Instance.UI.Language.Value    = info;
            PdnResources.Culture = info;
            AppSettings.Instance.UI.ErrorFlagsAtStartup.Value = AppSettings.Instance.UI.ErrorFlags.Value;
            WorkItemDispatcher.Initialize(AppSettings.Instance.Performance.ThreadUtilizationPolicy.Value);
            UIUtil.IsGetMouseMoveScreenPointsEnabled = AppSettings.Instance.UI.EnableSmoothMouseInput.Value;
            if (!OS.VerifyFrameworkVersion(4, 6, 0, OS.FrameworkProfile.Full))
            {
                string message = PdnResources.GetString("Error.FXRequirement");
                MessageBoxUtil.ErrorBox(null, message);
                string fxurl = "https://www.microsoft.com/en-us/download/details.aspx?id=53345";
                () => ShellUtil.LaunchUrl2(null, fxurl).Eval <bool>().Observe();
            }
            else if (!OS.VerifyWindowsVersion(6, 1, 1))
            {
                string str4 = PdnResources.GetString("Error.OSRequirement");
                MessageBoxUtil.ErrorBox(null, str4);
            }
            else if (!Processor.IsFeaturePresent(ProcessorFeature.SSE))
            {
                string str5 = PdnResources.GetString("Error.SSERequirement");
                MessageBoxUtil.ErrorBox(null, str5);
            }
            else
            {
                string str;
                if (MultithreadedWorkItemDispatcher.IsSingleThreadForced && PdnInfo.IsFinalBuild)
                {
                    throw new PaintDotNet.InternalErrorException("MultithreadedWorkItemDispatcher.IsSingleThreadForced shouldn't be true for Final builds!");
                }
                if (RefTrackedObject.IsFullRefTrackingEnabled && PdnInfo.IsFinalBuild)
                {
                    throw new PaintDotNet.InternalErrorException("Full ref tracking should not be enabled for non-expiring builds!");
                }
                PaintDotNet.Base.AssemblyServices.RegisterProxies();
                PaintDotNet.Core.AssemblyServices.RegisterProxies();
                PaintDotNet.Framework.AssemblyServices.RegisterProxies();
                ObjectRefProxy.CloseRegistration();
                remainingArgs = TryRemoveArg(remainingArgs, "/showCrashLog=", out str);
                if (!string.IsNullOrWhiteSpace(str))
                {
                    DialogResult?nullable = null;
                    try
                    {
                        string fullPath = Path.GetFullPath(str);
                        if (File.Exists(fullPath))
                        {
                            nullable = new DialogResult?(CrashManager.ShowCrashLogDialog(fullPath));
                        }
                    }
                    catch (Exception exception)
                    {
                        try
                        {
                            MessageBox.Show(exception.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                        catch (Exception exception2)
                        {
                            Environment.FailFast(null, exception2);
                        }
                    }
                    DialogResult?nullable2 = nullable;
                    DialogResult oK        = DialogResult.OK;
                    if ((((DialogResult)nullable2.GetValueOrDefault()) == oK) ? nullable2.HasValue : false)
                    {
                        string[] args = new string[] { "/sleep=1000" };
                        StartNewInstance(null, false, args);
                    }
                }
                else
                {
                    string str2;
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Startup.OnCurrentDomainUnhandledException);
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, false);
                    Application.ThreadException += new ThreadExceptionEventHandler(Startup.OnApplicationThreadException);
                    this.canUseCrashDialog       = true;
                    remainingArgs = TryRemoveArg(remainingArgs, "/test", out str2);
                    if (str2 != null)
                    {
                        PdnInfo.IsTestMode = true;
                    }
                    SingleInstanceManager disposeMe = new SingleInstanceManager(mutexName);
                    animationService = null;
                    try
                    {
                        DirectWriteFactory.DefaultDirectWriteSettingsController defaultDirectWriteSettingsController;
                        DrawingContext.DefaultDrawingContextSettingsController  defaultDrawingContextSettingsController;
                        IDisposable               updatesServiceShutdown;
                        IUpdatesServiceHost       updatesServiceHost;
                        PdnSynchronizationContext pdnSyncContext;
                        if (!disposeMe.IsFirstInstance)
                        {
                            disposeMe.FocusFirstInstance();
                            foreach (string str7 in remainingArgs)
                            {
                                disposeMe.SendInstanceMessage(str7, 30);
                            }
                            disposeMe.Dispose();
                            disposeMe = null;
                        }
                        else
                        {
                            CleanupService.Initialize();
                            ResourcesService.Initialize();
                            UserFilesService.Initialize();
                            UserPalettesService.Initialize();
                            animationService           = AnimationService.Initialize();
                            animationService.IsEnabled = true;
                            Document.Initialize(PdnInfo.Version);
                            Layer.Initialize(PdnResources.GetString("Layer.BackgroundLayer.DefaultName"));
                            Effect.SetDefaultServiceProviderValueFactory(effect => new ServiceProviderForEffects());
                            defaultDirectWriteSettingsController = DirectWriteFactory.GetDefaultSettingsController();
                            defaultDirectWriteSettingsController.DefaultCulture = AppSettings.Instance.UI.Language.Value;
                            AppSettings.Instance.UI.Language.ValueChangedT     += (sender, e) => (defaultDirectWriteSettingsController.DefaultCulture = e.NewValue);
                            AeroColors.CurrentScheme = AppSettings.Instance.UI.AeroColorScheme.Value;
                            AppSettings.Instance.UI.AeroColorScheme.ValueChangedT += (sender, e) => (AeroColors.CurrentScheme = e.NewValue);
                            defaultDrawingContextSettingsController = DrawingContext.GetDefaultSettingsController();
                            defaultDrawingContextSettingsController.DefaultTextAntialiasMode = AppSettings.Instance.UI.DefaultTextAntialiasMode.Value;
                            AppSettings.Instance.UI.DefaultTextAntialiasMode.ValueChangedT  += delegate(object sender, ValueChangedEventArgs <TextAntialiasMode> e) {
                                defaultDrawingContextSettingsController.DefaultTextAntialiasMode = e.NewValue;
                                foreach (Form form in Application.OpenForms)
                                {
                                    form.PerformLayoutRecursiveDepthFirst("TextAntialiasMode");
                                    form.Invalidate(true);
                                }
                            };
                            defaultDrawingContextSettingsController.DefaultTextRenderingMode = AppSettings.Instance.UI.DefaultTextRenderingMode.Value;
                            AppSettings.Instance.UI.DefaultTextRenderingMode.ValueChangedT  += delegate(object sender, ValueChangedEventArgs <TextRenderingMode> e) {
                                defaultDrawingContextSettingsController.DefaultTextRenderingMode = e.NewValue;
                                foreach (Form form in Application.OpenForms)
                                {
                                    form.PerformLayoutRecursiveDepthFirst("TextRenderingMode");
                                    form.Invalidate(true);
                                }
                            };
                            PaintDotNet.IndirectUI.ControlInfo.Initialize(Assembly.GetExecutingAssembly());
                            PdnBaseForm.SetStaticHelpRequestedHandler(delegate(object sender, HelpEventArgs e) {
                                HelpService.Instance.ShowHelp(sender as IWin32Window);
                                e.Handled = true;
                            });
                            Control control = new Control();
                            SynchronizationContext current = SynchronizationContext.Current;
                            PdnSynchronizationContextController controller = PdnSynchronizationContext.Install(new WaitForMultipleObjectsExDelegate(WaitHelper.WaitForMultipleObjectsEx), new SleepExDelegate(WaitHelper.SleepEx));
                            pdnSyncContext         = controller.Instance;
                            this.mainForm          = new MainForm(remainingArgs);
                            updatesServiceHost     = this.mainForm.CreateUpdatesServiceHost();
                            updatesServiceShutdown = null;
                            EventHandler initUpdatesOnShown = null;
                            initUpdatesOnShown = delegate(object sender, EventArgs e) {
                                this.mainForm.Shown   -= initUpdatesOnShown;
                                updatesServiceShutdown = UpdatesService.Initialize(updatesServiceHost);
                            };
                            this.mainForm.Shown += initUpdatesOnShown;
                            this.mainForm.SingleInstanceManager = disposeMe;
                            disposeMe = null;
                            int num        = (int)Math.Floor((double)8.3333333333333339);
                            int intervalMs = (int)Math.Floor((double)50.0);
                            using (AnimationTimerUpdateThread timerThread = new AnimationTimerUpdateThread(intervalMs, false))
                            {
                                < > c__DisplayClass20_1 class_3;