Skip to content

Commit

Permalink
Vanquish the curse of transform async, but for List now (#612)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomáš Filip <tomas.filip@meac.cz>
  • Loading branch information
tomasfil and Tomáš Filip authored Jun 25, 2022
1 parent 9e17d5e commit 4054f13
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/DynamicData/List/Internal/TransformAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ public IObservable<IChangeSet<TDestination>> Run()
observer =>
{
var state = new ChangeAwareList<TransformedItemContainer>();
var asyncLock = new SemaphoreSlim(1, 1);
return _source.Select(
async changes =>
{
await Transform(state, changes).ConfigureAwait(false);
return state;
try
{
await asyncLock.WaitAsync().ConfigureAwait(false);
await Transform(state, changes).ConfigureAwait(false);
return state;
}
finally
{
asyncLock.Release();
}
}).Select(tasks => tasks.ToObservable()).SelectMany(items => items).Select(
transformed =>
{
Expand Down

0 comments on commit 4054f13

Please sign in to comment.