AnsweredAssumed Answered

AF SDK  asnyc Add AFElements Not SHOWING up in PSE?? not sure why..

Question asked by ChewCheeLim on May 16, 2016
Latest reply on May 18, 2016 by bshang

Hi, I am trying to do async add AF elements with AF SDK. it seems the add changes went through but newly added Elements not showing up in PSE. I also got the GUID keys back from the AFElement added. I have code snippet here. Could someone please help? any coding error ?



Code snippet. (console)




static void Main(string[] args)


Console.WriteLine("Async list of elements creation");


Console.WriteLine("Enter to begin :");




//keys pulled from xml export from PSE with unique keys

Guid parentKey = Guid.Parse("b7de2364-1b6c-11e6-b7cf-00155d43539a"); //Outlets

Guid parentkey2 = Guid.Parse("b7de2361-1b6c-11e6-b7cf-00155d43539a"); //Inlets

List<Task> list = new List<Task>();


for (var i = 6; i < 3; i++)


List<string> listA = new List<string>();


"CC_Outlet0" + i);


var task = Task.Factory.StartNew(() =>


"ADCOneLine_Dev", parentKey, listA);


for (var i = 6; i < 2; i++)


List<string> listB = new List<string>();


"CC_Inlets0" + i);


var task = Task.Factory.StartNew(() =>


"ADCOneLine_Dev", parentkey2, listB);




Console.WriteLine("Elements created !!");


Console.WriteLine("Enter to exit ..");




/// <summary>

/// method to mimic common method call

/// </summary>

public static void AddEMElementsMultipleParents(string afDb, Guid parentKey, List<string> listToAdd)


PISystems piSystemLibs = new PISystems();




PISystem piSystem = piSystemLibs["EMDEVCLDAF01"];


if (piSystem == null)


throw new Exception("Invalid Server");


AFDatabase af = piSystem.Databases[afDb];


AFNamedCollectionList<AFElement> getParents = AFElement.LoadElements(af.PISystem, new Guid[] { parentKey }, null);


AFElement myParent = getParents.ElementAtOrDefault(0);


if (myParent == null) throw new Exception("Incorrect parent key! ");


foreach (string  elementName in listToAdd)