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

  • SEARCH
  • Home
  • 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 7767289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:38:24+00:00 2026-06-01T15:38:24+00:00

i have made a small opengl program using the d programming language. what i

  • 0

i have made a small opengl program using the d programming language. what i am trying to do is to allow the program to read input from the console. i have tried to use readf(), getc() and some other functions. but my problem is i don’t want the program to pause while looking for input.

i have tried to search around for a solution but could not find any. so if anyone know how to check if something actually have been written in the console and if so read that. or if there exists any function that reads from console, but will be ignored if nothing gets written.

i mainly would like to know how to do this in d but a solution for c++ could be useful too.

  • 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-01T15:38:25+00:00Added an answer on June 1, 2026 at 3:38 pm

    You need to use a separate thread. Something like this is one way to do it in D:

    import std.stdio, std.concurrency;
    
    void main()
    {
        // Spawn a reader thread to do non-blocking reading.
        auto reader = spawn(()
        {
            // Read console input (blocking).
            auto str = readln();
    
            // Receive the main thread's TID and reply with the string we read.
            receive((Tid main) { send(main, str); });
        });
    
        // ... This is where you can do work while the other thread waits for console input ...
    
        // Let the reader thread know the main thread's TID so it can respond.
        send(reader, thisTid);
    
        // Receive back the input string.
        receive((string str) { writeln("Got string: ", str); });
    }
    

    This spawns a separate thread which does the console input waiting while your main thread can do other work.

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

Sidebar

Related Questions

Problem: Have made a small mail program which works perfectly on my developer pc
I have just started programming and have made a few small applications in C
I have made a program which is a small library operated via software. When
i have made an small script to allow users to build they page or
I am studying memory management, and I have made a small program which manages
I have made a demo small program that I want to deliver to my
I have made a small program in c# called Registry.exe. Now i my c++
I have made a small log service that i want to publish to a
I have made a small application in Java and I would like to make
Post-release, I have made one small change to one form in our development site

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.