Exemplo n.º 1
0
        public override IEnumerable <DebugAllocationData> Run()
        {
            if (!isInitialized)
            {
                var input = StartupInput.GetDefault();
                GdiplusStartup(out initToken, ref input, out var output);
                AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
                {
                    GdiplusShutdown(new HandleRef(null, initToken));
                };
                isInitialized = true;
            }

            for (int i = 0; i < 10; i++)
            {
                long beforeAlloc = Environment.WorkingSet;

                BitmapImage image = new BitmapImage(FilePath);

                long afterAlloc = Environment.WorkingSet;

                long afterDispose = Environment.WorkingSet;

                yield return(new DebugAllocationData(beforeAlloc, afterAlloc, afterDispose));
            }
        }
Exemplo n.º 2
0
            static Gdip()
            {
                Debug.Assert(s_initToken == IntPtr.Zero, "GdiplusInitialization: Initialize should not be called more than once in the same domain!");

                PlatformInitialize();

                StartupInput input = StartupInput.GetDefault();

                // GDI+ ref counts multiple calls to Startup in the same process, so calls from multiple
                // domains are ok, just make sure to pair each w/GdiplusShutdown
                int status = GdiplusStartup(out s_initToken, ref input, out StartupOutput output);

                CheckStatus(status);
            }
Exemplo n.º 3
0
            static Gdip()
            {
                Debug.Assert(s_initToken == IntPtr.Zero, "GdiplusInitialization: Initialize should not be called more than once in the same domain!");
                Debug.WriteLineIf(s_gdiPlusInitialization.TraceVerbose, "Initialize GDI+ [" + AppDomain.CurrentDomain.FriendlyName + "]");
                Debug.Indent();

                PlatformInitialize();

                StartupInput input = StartupInput.GetDefault();

                // GDI+ ref counts multiple calls to Startup in the same process, so calls from multiple
                // domains are ok, just make sure to pair each w/GdiplusShutdown
                int status = GdiplusStartup(out s_initToken, ref input, out StartupOutput output);

                CheckStatus(status);

                Debug.Unindent();
            }
Exemplo n.º 4
0
            private static void Initialize()
            {
                var input = StartupInput.GetDefault();

                var status = GdiplusStartup(out InitToken, ref input, out _);

                if (status != Ok)
                {
                    throw StatusException(status);
                }

                var currentDomain = AppDomain.CurrentDomain;

                currentDomain.ProcessExit += OnProcessExit;

                if (!currentDomain.IsDefaultAppDomain())
                {
                    currentDomain.DomainUnload += OnProcessExit;
                }
            }