Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:23:07+00:00 2026-06-05T18:23:07+00:00

I currently have an application I’m writing in c# (using .NET) that requires me

  • 0

I currently have an application I’m writing in c# (using .NET) that requires me to start a timer as soon as a user sees an image on screen up until they respond with a key press.

Now I realise that practically this is very difficult given the monitor input lag and response time, the time the keyboard takes to physically send the message, the OS to process it, etc.

But I’m trying my best to reduce it down to mostly a constant error (the response time results will be used to compare one user to the next so a constant error isn’t really an issue). However annoying hurdle is the variable caused by the monitor refresh rate, as I gather when my onPaint message is called and done with, it doesn’t mean the image has actually been processed and sent from the graphics buffer?

Unfortunately time restrictions and other commitments would realistically restrict me to continuing this task in c# for windows.

So what I was wondering was if either handling all the drawing in OpenGL or DirectX or better still for me if it is possible to just using either OpenGL or DirectX to create an event when the screen is updated?

Another suggestion given to me previously was regarding V-Sync, if I switch this off is the image sent as soon as it is drawn? as opposed to sending images at a set rate synchronised to the monitor refresh rate?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:23:09+00:00Added an answer on June 5, 2026 at 6:23 pm

    You must render your graphic in a separate thread in order to:

    • Use vertical synchronisation to have a precise timing of the effective display of your image.
    • Get the precise timing of your user input (since user interface is not on the same thread than the render loop.

    Initialise Direct3D to enable the VSync during render :

    // DirectX example
    presentParams.SwapEffect = SwapEffect.Discard;
    presentParams.BackBufferCount = 1;
    presentParams.PresentationInterval = PresentInterval.One;
    
    device = new Device(...
    

    Perform the render in a separate thread:

    Thread renderThread = new Thread(RenderLoop);
    renderThread.Start();
    
    shouldDisplayImageEvent = new AutoResetEvent();
    

    Then use the following render loop:

    void RenderLoop()
    {
        while(applicationActive)
        {
              device.BeginScene();
    
            // Other rendering task
    
            if (shouldDisplayImageEvent.WaitOne(0))
            {
                // Render image
                // ...
    
                userResponseStopwatch = new Stopwatch();
                userResponseStopwatch.Start();
            }
    
            device.EndScene();
    
            device.Present();
        }
    }
    

    Then handle the user input :

    void OnUserInput(object sender, EventArgs e)
    {
        if (userResponseStopwatch != null)
        {
            userResponseStopwatch.Stop();
    
            float userResponseDuration = userResponseStopwatch.ElapsedMillisecond - 1000 / device.DisplayMode.RefreshRate - displayDeviceDelayConstant;
            userResponseStopwatch = null;
        }
    }
    

    You now use the shouldDisplayImageEvent.Set() event trigger to display the image as needed and start the stop watch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application in java (1.6) using swing. I currently have a
I currently have a web-application that implements a rudimentary form of ACL using UNIONs
I have an application that requires synchronization and I wanted to inform the user
currently we have an application that is configured by using a datasource inside a
I currently have a web application that I would like to scale out using
We have a console application (currently .NET) that sends out mail in bulk to
I have an application that requires the user to reenter their password between 15
Currently I have an application that connects to a Terminal Server over TCP/IP using
We currently have an application that depends largely on stored procedures. There is a
I currently have an application that uses a browserfield to access an internet page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.