When my app starts for the first time it needs to generate some default data. In my code I show a message thanking them for purchasing and informing them that default data will then be generated. When they OK this message the code generates the data and when that has completed another message is shown telling them that the app is ready to use.
However
What happens is, when the app starts the first message is not shown until after the data is created and then the second message is not shown at all.
When I used the original message box it worked fine.
Any ideas?
7 Answers, 1 is accepted
Thank you for writing.
When you debug the application you should notice that the call to our RadMessageBox.Show() method returns immediately, while Microsoft's message box blocks the UI thread. This is why the standard message box is shown before your data is generated and ours shows after it is generated. In other words, the MessageBox.Show() method is snychronous, while RadMessageBox.Show() is asynchronous.
RadMessageBox is implemented asynchronously because there is no other way to implement it in Silverlight. In order for the Show method to block the UI thread we need low level native APIs that allow the installation of a modal message loop, however these APIs are not available to developers.
What you have to do, is to show RadMessageBox initially. Then, in the message box closed, callback you generate your data. Now after your data is generated, you show the second message box.
For example:
this.Loaded += (s, a) =>
{
RadMessageBox.Show("Title", closedHandler: (args) =>
{
// generate data.
this.Dispatcher.BeginInvoke(() => RadMessageBox.Show("Second message box"));
});
};
Please write again if you have other questions. Regards,
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Ian
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
//check to see if settings have been changed
string onBackPressSettings = lpConcUnits.SelectedIndex.ToString() + lpVolUnits.SelectedIndex.ToString() + lpMassUnits.SelectedIndex.ToString();
if (onOpenSettings != onBackPressSettings)
{
this.Loaded += (s, a) =>
RadMessageBox.Show("Title", closedHandler: (args) =>
{
// generate data.
this.Dispatcher.BeginInvoke(() => RadMessageBox.Show("Second message box"));
});
}
any help much appreciated
Thanks for writing.
As mentioned earlier, the Show() method of RadMessageBox is asynchronous. Therefore, when you call it on back key press, it returns immediately and you go back to the previous page of your app or the app exits. What you have to do, is when you determine that you should show the message box, you have to cancel the back key press and then show the message box.
Please write again if you need further assistance.
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
http://www.telerik.com/help/windows-phone/messagebox-gettingstarted-gettingstarted.html
Thanks for the feedback. I agree, we will add this bit to the getting started page.
Regards,Victor
the Telerik team