P
Priya Bange
Guest
Hi Experts,
Could any one please share how I can add an item to Concurrent bag for the following requirement. I basically created a class named BagStructure & need to add data to it. am new to C#.
Am trying to add a value like below which works for Data Table but not sure how to do for Concurrent Bag when I have multiple elements like event_name, object_name, object_id, object_type
class BagStructure
{
public string Event_Name { get; set; }
public string object_name { get; set; }
public Int32 object_id { get; set; }
public string object_type { get; set; }
}
public static void LoadFile(string InputFilePath, string tableName)
{
var data = new ConcurrentBag<BagStructure>();
var xeStream = new XEFileEventStreamer(InputFilePath);
xeStream.ReadEventStream(
xevent =>
{
XEextract(xevent, data);
return Task.CompletedTask;
},
CancellationToken.None).Wait();
}
private static void XEextract(IXEvent xe, ConcurrentBag<QueryPerfStructure> data)
{
xe.Fields.TryGetValue("object_id", out object object_id);
data.Add.object_id = object_id == null ? 0 : object_id;
xe.Fields.TryGetValue("object_name", out object object_name);
data.Add.["object_name"] = object_name == null ? string.Empty : object_name;
xe.Fields.TryGetValue("object_type", out object object_type);
data.Add.["object_type"] = object_type == null ? string.Empty : object_type;
}
Thanks Priya
Continue reading...
Could any one please share how I can add an item to Concurrent bag for the following requirement. I basically created a class named BagStructure & need to add data to it. am new to C#.
Am trying to add a value like below which works for Data Table but not sure how to do for Concurrent Bag when I have multiple elements like event_name, object_name, object_id, object_type
class BagStructure
{
public string Event_Name { get; set; }
public string object_name { get; set; }
public Int32 object_id { get; set; }
public string object_type { get; set; }
}
public static void LoadFile(string InputFilePath, string tableName)
{
var data = new ConcurrentBag<BagStructure>();
var xeStream = new XEFileEventStreamer(InputFilePath);
xeStream.ReadEventStream(
xevent =>
{
XEextract(xevent, data);
return Task.CompletedTask;
},
CancellationToken.None).Wait();
}
private static void XEextract(IXEvent xe, ConcurrentBag<QueryPerfStructure> data)
{
xe.Fields.TryGetValue("object_id", out object object_id);
data.Add.object_id = object_id == null ? 0 : object_id;
xe.Fields.TryGetValue("object_name", out object object_name);
data.Add.["object_name"] = object_name == null ? string.Empty : object_name;
xe.Fields.TryGetValue("object_type", out object object_type);
data.Add.["object_type"] = object_type == null ? string.Empty : object_type;
}
Thanks Priya
Continue reading...