This is a migrated thread and some comments may be shown as answers.

Problem with threads? how RadWindow.Show() works?

2 Answers 127 Views
Window
This is a migrated thread and some comments may be shown as answers.
Celeste
Top achievements
Rank 1
Celeste asked on 06 Jul 2009, 02:06 PM

I have implemented a UserControl which works like System,Windows.MessageBox using RadWindow.
The control allows to use Buttons inside of it.
I want to implement the method Show just like System,Windows.MessageBox, returning pressed button.
So I have a var in control named buttonpressed, which is setted once some button was clicked.

Manager event, buttonClick:

        private void buttonClick(object sender, RoutedEventArgs e)  
        {  
            Button b = (Button)sender;  
            MsgBoxButton botonType = (MsgBoxButton)b.Content;  
 
            this.window_Win.Hide();  
            this.buttonPressed = botonType;              
        } 

And in the method Show I have the next code:

       public static MsgBoxButton Show(MessageBoxType type, string header, string message, string detail,MsgBoxButtonCollection buttons)  
        {  
           MsgBox box = new MsgBox();              
 
           box.Type = type;  
           box.Header = header;  
           box.Message = message;  
           box.Detail = detail;              
           box.CreateButtons(buttons,null,null);  
           /*box.Show() only calls RadWindow.Show()*/ 
           box.Show();   
 
            while (box.buttonPressed == null)  
            {  
                  
            }  
 
            return box.buttonPressed;  
        } 

the problem is that the window is not showned when I call box.Show(). The code below is executed, and it ends with an infinite loop.
I suppose it is a problem with threads. Can you help me?

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Borisov
Telerik team
answered on 07 Jul 2009, 02:35 PM
Hi Celeste,

This is a limitation of Silverlight, since there is no way you can stop the execution thread and get synchronous results. This is one of the reason our RadWindow doesn't work synchronously,e.g. wait for the Show method to return result before continuing the execution. We have this feature in our ToDo list, but we still haven't found a solution that gets around this problem.

Kind regards,
Hristo Borisov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Murray
Top achievements
Rank 2
answered on 24 Jan 2012, 09:10 PM
Hristo, how is this a limitation of Silverlight when the out-of-the-box MessegeBox performs synchronously?

We are having the same issue as Celeste with your Message dialogs not blocking the background thread until we get a user response (hence synchronous).

This has become a major issue for us and currently we are resorting to the Microsoft MessegeBox implimentation which is not ideal due to styling issues with the Microsoft control.
Tags
Window
Asked by
Celeste
Top achievements
Rank 1
Answers by
Hristo Borisov
Telerik team
Murray
Top achievements
Rank 2
Share this question
or