-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
Hi @StendProg, in #692 @jl0pd commented about this method:
ScottPlot/src/ScottPlot/Plottable/DataStructures/Segmentedtree.cs
Lines 54 to 60 in 2b15737
| public async Task SetSourceAsync(T[] data) | |
| { | |
| if (data == null) | |
| throw new Exception("Data cannot be null"); | |
| sourceArray = data; | |
| await Task.Run(() => UpdateTreesInBackground()); | |
| } |
@jl0pd said we are not awaiting real operation, but only the creation of a task. By doing this users may begin to work data which is not yet updated properly. This solution was offered:
public async Task SetSourceAsync(T[] data)
{
sourceArray = data ?? throw new ArgumentNullException("Data cannot be null");
await Task.Run(() => UpdateTrees());
}This makes sense to me, as UpdateTreesInBackground() is just Task.Run(() => { UpdateTrees(); }), but before making this change I wanted to double check and make sure it looks good to you too. @StendProg, what do you think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels