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
NativeApi.InitializeAsync() not really async #274
Comments
NativeApi.InitializeAsync()
not really async
This is perhaps something we should do for all the native calls? |
Coming back to this after a too long hiatus. It seems the recommended way to wrap sync calls in async contexts is to do: // Custom delegates not supported so have to wrap in a lambda
var result = await Task.Run(() => _nativeSdkMethods.Init());
// handle result Updating all the methods in |
After a long hiatus myself, I've found myself acquiring a better understanding on how async/await works. Given that Besides this, there's the fact that the Chroma SDK will take way longer (around 1 second on my machine) to get initialized internally and be ready to accept commands. The only way to check on this, though, is by listening for the |
Hm, that might be the way to go. Document it and then users can either use the event loop if they have it available (optimal), or insert an artificial delay of a second or two that should leave enough time to init (not as accurate, but probably good enough if it's not feasible to get the event loop). |
Latest docs in release branch now have a note in the getting started guide about needing to wait for a couple seconds or use the method of listening for the |
Currently
NativeApi.InitializeAsync()
wrapsNativeSdkMethods.Init()
to return aTask
. However,NativeSdkMethods.Init()
does take a while to start (about 300ms on my laptop), blocking the calling thread.I'd suggest to spin a new thread doing something like this:
Thoughts?
The text was updated successfully, but these errors were encountered: