C
C#15mo ago
SWEETPONY

✅ how to stop the task in this case?

I have following method:
private async Task<ReportDataSet> PrepareDataSet()
{
var dataSet = new ReportDataSet();

await _archiveClient.QueryChunks(
arguments: new()
{
TimestampInterval = _parameters.TimestampInterval,
EventCategories = _parameters.EventCategories,
EventNames = _parameters.EventNames,
OperatorIDs = _parameters.OperatorIDs,
SubjectIDs = _parameters.SubjectIDs,
DepartmentIDs = _parameters.DepartmentIDs,
TerritoryIDs = _parameters.TerritoryIDs,
AccessPointIDs = _parameters.AccessPointIDs
},
chunkCallback: async items => await FillDataSetChunk(dataSet, items),
parameters: new()
{
User = _context.Principal.Name
} );

return dataSet;
}
private async Task<ReportDataSet> PrepareDataSet()
{
var dataSet = new ReportDataSet();

await _archiveClient.QueryChunks(
arguments: new()
{
TimestampInterval = _parameters.TimestampInterval,
EventCategories = _parameters.EventCategories,
EventNames = _parameters.EventNames,
OperatorIDs = _parameters.OperatorIDs,
SubjectIDs = _parameters.SubjectIDs,
DepartmentIDs = _parameters.DepartmentIDs,
TerritoryIDs = _parameters.TerritoryIDs,
AccessPointIDs = _parameters.AccessPointIDs
},
chunkCallback: async items => await FillDataSetChunk(dataSet, items),
parameters: new()
{
User = _context.Principal.Name
} );

return dataSet;
}
I wanna stop chuckCallback and return dataSet; if dataSet.Count == 5000 how can I do it?
3 Replies
SiloCitizen3
SiloCitizen315mo ago
Isnt this a perfect use case for a CancellationToken?
Florian Voß
Florian Voß15mo ago
If(dataSet.Count == 5000) return dataSet; 🤔 In first line of the delegate
SWEETPONY
SWEETPONYOP15mo ago
it will not work ah lol it works, I'm stupid asf I already tried this and it didn't work so I decided it is wrong answer thanks
Want results from more Discord servers?
Add your server