Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ ReadConsoleInput not working with boost::thread
    primarykey
    data
    text
    <p>I've created to create a listener class that will call methods such as on_left_mouse_released on a controller object. It works fine, and now I am trying to have it run in another thread using boost::thread. However, I seem to be doing something wrong. I am new to multithreading, so this could easily be a simple error.</p> <p>Here are selected portions from the listener class:</p> <pre><code>void Listener::listen() { keepListening = true; while(keepListening) { if(timerEnabled) { this-&gt;CheckForTimerEvent(); if( !PendingMouseOrKeyEvents()) //readconsoleinput is blocking continue; } if(!keepListening) //could have been changed in a timer event break; if(!mouseEnabled &amp;&amp; !keyboardEnabled) continue; ReadConsoleInput(hIn, &amp;InRec, 1, &amp;NumRead); //see http://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx //for more information on InRec and its submembers if(mouseEnabled &amp;&amp;InRec.EventType == MOUSE_EVENT) { this-&gt;ProcessMouseEvent(InRec.Event.MouseEvent); cout &lt;&lt; "here"; } else if(keyboardEnabled &amp;&amp; InRec.EventType == KEY_EVENT) { this-&gt;ProcessKeyEvent(InRec.Event.KeyEvent); cout &lt;&lt; "here"; } } } void Listener::operator()() { listen(); } </code></pre> <p>In my main function, if I create a Listener object named listener, then say "listener();" both of the couts occur with the appropriate events. However, if I use "boost::thread listen (boost::ref(listener));" instead, nothing happens. </p> <p>Does anyone see why this is?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload