示例#1
0
        /// <summary>
        /// Fetches the entity loist from CRM and display it under selct entity combobox control
        /// </summary>
        private void CrmEntitiesFetch()
        {
            WorkAsync(new WorkAsyncInfo
            {
                // Showing message until background work is completed
                Message = "Retrieving Entities Information",

                // Main task which will be executed asynchronously
                Work = (worker, args) =>
                {
                    CrmHelper crmHelper = new CrmHelper(Service);
                    args.Result         = crmHelper.GetEntitylist();
                },

                // Work is completed, results can be shown to user
                PostWorkCallBack = (args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    // Binding result data to ListBox Control
                    var result = args.Result as List <EntityMetadata>;
                    selectEntitiesComboBox.Items.Clear();
                    selectAttributeComboBox.Items.Clear();
                    foreach (var entityMetadata in result)
                    {
                        selectEntitiesComboBox.Items.Add(entityMetadata);
                    }
                }
            });
        }