Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
C#
public partial class MainWindow : Window
   {
       public MainWindow()
       {
           InitializeComponent();
           Thread thread = new Thread(GetValue);
           Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                         new Action(thread.Start));
           MessageBox.Show("Show Down");
           int i = 0;
           while (i == 0)
           {
               if (thread.IsAlive)
               {
                   thread.Join();
                   i++;
               }
           }
       }

       public void GetValue()
       {
           MessageBox.Show("Show Up");
       }
   }
Posted

1 solution

Hi Nitin, Good question.
I think that Dispatcher is starting the thread whenever there is any UI change(MessageBox). Try adding any other non UI lines like assignment to variables before the while and remove MessageBox, it won't work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900