Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StartMessageLoop only called once before blocking #2

Open
TobyD opened this issue Nov 3, 2011 · 1 comment
Open

StartMessageLoop only called once before blocking #2

TobyD opened this issue Nov 3, 2011 · 1 comment

Comments

@TobyD
Copy link

TobyD commented Nov 3, 2011

There is a good chance that I am doing something wrong, but when trying to implement some event callbacks for a Lecroy Voyager M3i USB analyzer I am finding that my call to StartMessageLoop() from a lua script will block. I took a look at the luacom_StartMessageLoop code in luacom.cpp and see that it is calling GetMessage - a blocking call. I'm not sure what the solution should be...perhaps using PeekMessage (with the PM_REMOVE parameter to remove the message after processing) instead of GetMessage? Although then the loop would only run until there are no more messages to process. For now I created a new method luacom_NextMessage (shown below) and I call it everytime I want to querry the queue. That seems to be working. Am I doing something wrong? Is this a bug? Is there a better way to ensure events get handled?

int luacom_NextMessage(lua_State *L)
{
  MSG msg;
  if(PeekMessage(&msg, NULL, 0, 0, 1)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return 0;
}
moteus referenced this issue in moteus/luacom Sep 29, 2016
Make codepage for lua string settable ( default is UTF-8)
@wunoman
Copy link

wunoman commented Feb 23, 2024

after start loop, you can send message to hwnd, and do what you want on message handler function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants