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.


  • AsurAsur USMember ✭✭✭

    @DavidOrtinau @JGoldberger any clue as to why this must be happening and if this can be a bug in forms . Am using forms.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    It is hard to say why you are getting that exception without seeing any code or even the type of exception that is being thrown with the related stack trace. A small test project that reproduces the issue would be the best way for us to investigate the issue and see if it is a bug in Forms or a bug in your code.

    If you want one on one email support along with the ability to share code privately and securely, please open a free Xamarin support case. You can open a free Xamarin support case here:

Sign In or Register to comment.