/// <summary>
        /// Make sure to call this after a Window context is made!
        /// </summary>
        /// <returns></returns>
        public static IVSyncContext CreateContext()
        {
            try
            {
                var openAdapter        = new D3DKMT_OPENADAPTERFROMHDC();
                var waitForVblankEvent = new D3DKMT_WAITFORVERTICALBLANKEVENT();

                var hdc = CreateDC(Screen.PrimaryScreen.DeviceName, null, null, IntPtr.Zero);
                openAdapter.hDc = hdc;
                var result = D3DKMTOpenAdapterFromHdc(ref openAdapter);
                if (result != 0)
                {
                    throw new Exception("D3DKMTOpenAdapterFromHdc failed");
                }

                waitForVblankEvent.hAdapter      = openAdapter.hAdapter;
                waitForVblankEvent.hDevice       = 0;
                waitForVblankEvent.VidPnSourceId = openAdapter.VidPnSourceId;

                return(new VsyncContext(waitForVblankEvent));
            }
            catch (Exception e)
            {
                ReportFactory.FallbackReport.Error(e);
            }

            return(new SimulatedVSync());
        }
 static extern uint D3DKMTWaitForVerticalBlankEvent(ref D3DKMT_WAITFORVERTICALBLANKEVENT pData);
 internal VsyncContext(D3DKMT_WAITFORVERTICALBLANKEVENT waitforverticalblankevent)
 {
     _waitforverticalblankevent = waitforverticalblankevent;
 }