diagram.BeginNodeRender and diagram.BeginNodeLayout and diagram.Loaded not fires

when i use async method to get data from web services the diagram.BeginNodeRender  and  diagram.BeginNodeLayout  and diagram.Loaded not fires in this code :


 public TreePage()
    {

        InitializeComponent();

                  LoadAsync();
    }





    public async void LoadAsync()
    {
            
                diagram.IsReadOnly = true;
                diagram.EnableSelectors = false;
                diagram.PageSettings.PageBackGround = Color.White;



                DataModel datamodel = new DataModel();

                
                DataSourceSettings settings = new DataSourceSettings();


        await datamodel.DataAsync();


                settings.ParentId = "ParentId";
                settings.Id = "UserId";
                settings.DataSource = datamodel.Users;
            
                 diagram.DataSourceSettings = settings;


                diagram.LayoutManager = new LayoutManager()
                {
                    Layout = new DirectedTreeLayout()
                    {
                        Type = LayoutType.Organization,
                        HorizontalSpacing = 20,
                        VerticalSpacing = 20
                    }
                };

                for (int i = 0; i < diagram.Connectors.Count; i++)
                {
                    diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                    diagram.Connectors[i].Style.StrokeBrush = new SolidBrush(Color.FromRgb(127, 132, 133));
                    diagram.Connectors[i].Style.StrokeWidth = 1;
                }

            // not fires

                diagram.BeginNodeRender +=  Diagram_BeginNodeRender;
                diagram.BeginNodeLayout += Diagram_BeginNodeLayout;
               
                diagram.Loaded += Diagram_Loaded;


        }


it only fires in  ( public  void LoadAsync() ) not in   (public async void LoadAsync() ) but i need       ( await datamodel.DataAsync(); ) in code so i make function is async



any solution for that please


1 Reply

AP Arun Prasad Matheshwaran Syncfusion Team May 14, 2018 01:28 PM UTC

Hi Samialfarra, 

We tried to reproduce the mentioned scenario by using the async method for generating DataModel, the data for organization chart is generated properly. Please find below the sample, which we tried to reproduce the scenario. 
Sample Link: 
We guess that you need a solution for applying templates to nodes after the web service or after any async task. 
For that you can try to call the wait method of the async task. 
Code Snippet: 
datamodel.DataAsync().Wait(); 
Below Microsoft link explaining an await expression does not block the thread on which it is executing, 

For further details regarding any queries, please let us know or create a support incident under your Directrac account. 

Thanks, 
Arun 


Loader.
Up arrow icon