question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NativeApi.InitializeAsync() not really async

See original GitHub issue

Currently NativeApi.InitializeAsync() wraps NativeSdkMethods.Init() to return a Task. 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:

return Task.Run(_nativeSdkMethods.Init)
   .ContinueWith(/* error handling */);

Thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Sharparamcommented, Feb 28, 2021

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 DeviceAccess event.

0reactions
Sharparamcommented, Jan 31, 2021

I’d rather document this clearly so users know what to expect.

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - InitializeAsync in MediaCapture doesnt work
You need to change your method like this: public async Task Foo() { //code try { MediaCapture mc = new MediaCapture(); await mc....
Read more >
UnityServices.InitializeAsync + ConfigurationBuilder. ...
I tried with an async method the result is the same - native crash on Android. Not exactly the same, the crash looks...
Read more >
Initialize StateNotifierProvider with async data · Issue #57
In this case I call getBaseData() to load base data from API to use in further screens (ex. HomeScreen -> SettingsScreen -> BaseDataScreen)....
Read more >
Asynchronous initialisation and cleanup operations with xUnit
I/O-bound operations are a great use case of asynchronous tasks, so I was wondering how xUnit would help me support this.
Read more >
Initialize Unity Gaming Services | In App Purchasing | 4.4.1
InitializeAsync() to initialize all Unity Gaming Services at once. It returns a Task that enables you to monitor the initialization's ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found