-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Error when using the Initialize event in a view model since upgrade to Version 6.0 #2808
Comments
What if you use |
Where exactly would I use this? I do want to await the calls in Initialize. I was thinking this was the whole purpose of having an async Initialize to do the heavy loading. It worked fine under version 5.x. I can use a workaround if that's what it will take. |
A good read on this is: https://medium.com/bynder-tech/c-why-you-should-use-configureawait-false-in-your-library-code-d7837dce3d7f It's not a workaround, it's what you are supposed to do. |
It is puzzling that this app has been working for years and now it has to be configured differently and only in the Initialize of a ViewModel. I had to add the ConfigureAwait(false) in the Initialize and in the call to the data service, but it started working. If you don't mind me asking, what is it about the Initialize event that makes you have to do this now? |
I think this is only true of the first view model. The first navigation is forced to be done synchronously. |
@nickrandolph it seems you are correct that it is only on the first View Model. After that, the other View Models work as expected. I am using a SplashScreen. Can you tell me what sort of initialization logic I could do to make the first View Model Initialization be asynchronous? |
@JimWilcox3 check out my post https://nicksnettravels.builttoroam.com/post/2018/04/19/MvvmCross-Initialize-method-on-the-first-view-model.aspx |
@nickrandolph Thanks for posting that. It was helpful and informative. |
https://github.com/JimWilcox3/MvvmCrossInitializeTest
Steps to reproduce 📜
The project will hang up if you run it as is. The View is never displayed.
If you comment out the ColorList = await SomeData.GetColors(); in the Initialize, the View is displayed but the colors are not loaded.
If you un-comment the Task in the constructor, the colors will load and the View will be displayed.
Expected behavior 🤔
You should be able to use an async Task to load data in the Initialize of the View Model.
Actual behavior 🐛
It makes the call to load the data then hangs and never shows the View.
Configuration 🔧
Version: 6.0
Platform:
The text was updated successfully, but these errors were encountered: