Please find the code here added in Window_Loaded event to create a label in Grid control dynamically from different task thread. once the task is completed I am able to see the label added from this code and other controls declared in the markup in the window. However the UI hangs indefinitely, not able to manipulate any controls. my query is how to switch control to main UI thread and interact with this control later when needed. your help would be grateful.
new Task(new Action(() =>{
this.mainGrid.Dispatcher.BeginInvoke(new Action(() =>
{
Label lbl = new Label();
lbl.Content = "Srikar";
lbl.Name = "lbldesc";
this.mainGrid.Children.Add(lbl);
}),System.Windows.Threading.DispatcherPriority.Normal);
})).Start();