Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Invoking MessagingCenter throws exception in a specific scenario. Works with Thread.Sleep

AsurAsur USMember ✭✭✭

I have a functionality where the user can switch on/off bluetooth(classic) from xamarin app. Need some set functions to execute based on that which am handling using the Broadcast Receiver of android and on state change am invoking MessagingCenter and then subscribing to it on the viewModel end which works like a charm.
Now strangely though am using Messaging Center throughout my app, but if I switch on the bluetooth directly without going into a flow where Messaging center is invoked It throws an exception. If I execute any other flow well and then go back then it works fine. Works fine with debug point set before the MessagingCenter.Send is called .
have fixed it (temporarily by adding Thread.Sleep for a second).
But am really curious as to why it might be happening .
Any clue is appreciated.
Thanks

Posts

Sign In or Register to comment.