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

3 posts, 1 answers
  1. Celeste
    Celeste avatar
    34 posts
    Member since:
    May 2009

    Posted 06 Jul 2009 Link to this post

    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.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.Show() only calls RadWindow.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. Answer
    Hristo Borisov
    Hristo Borisov avatar
    298 posts

    Posted 07 Jul 2009 Link to this post

    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.
  3. Murray
    Murray avatar
    121 posts
    Member since:
    Aug 2010

    Posted 24 Jan 2012 Link to this post

    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.
Back to Top