I am working on C# Parallel.ForEach
loop. Within the parallel loop, I am calling async method ProcessMyData
and ProcessMyData
calling another async method GetMarkedData
where in GetMarkedData
method, I am calling the API services to pull record from database via Azure Function API but with parallel loop, I never received data for first thread while this method GetMarkedData
been called for remaining record and I never receive data in parallel loop however it do work fine in classic loop.
Parallel.ForEach(myList, options, async item=>
{
var processDataList = await ProcessMyData(item.Id);
});
protected async Task<List<myRecord>> ProcessMyData(recordId)
{
//my code...
var data = await GetMarkedData(recordId);
// remaining code...
}
public virtual async Task<IEnumerable<Record>> GetMarkedData(recordId id)
{
using (var myService = HttpClientUtilities...)
{
var markedRecordlist = myService.GetData(...)
}
}