Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

The C callback function registered through ffi invalidates both asynchronous operations and timers during the callback #213

Closed
lujun495904500 opened this issue Sep 17, 2023 · 2 comments

Comments

@lujun495904500
Copy link

// asynchronous operation test
void asyncTest() async {
  await Future.value(12);
  print('async test');
}

// timer test
void timerTest() async {
  print('timer test');
}

...
// c callback function registered through ffi
glfwSetKeyCallback(window, (window, key, scancode, action, mods) {
    if (GLFW_RELEASE == action) {
      if (GLFW_KEY_SPACE == key) {
        print('key code : $key');
        test();
        Timer(Duration(milliseconds: 10), testKeyCallback);
      }
    }
  });

Press space and output:

key code : 32

quit program and output:

key code : 32
async test
timer test
@dcharkes
Copy link
Contributor

Hi @lujun495904500!

I'm not entirely sure I understand your problem. Could you elaborate on the expected behavior and the actual behavior.

Also, could you provide a reproduction in a repo? Then I can look at all the code, the code above is incomplete.

@lujun495904500
Copy link
Author

Thanks for your answer, and finally checked, it is really my logic question @dcharkes

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants