@@ -151,12 +151,12 @@ protected override void ProcessPendingRender()
151151 // where one will read the current render tree (find components)
152152 // while the other thread (the renderer) updates the
153153 // render tree.
154- lock ( renderTreeAccessLock )
155- {
154+ // lock (renderTreeAccessLock)
155+ // {
156156 logger . LogProcessingPendingRenders ( ) ;
157157
158158 base . ProcessPendingRender ( ) ;
159- }
159+ // }
160160 }
161161
162162 /// <inheritdoc/>
@@ -271,21 +271,26 @@ private TResult Render<TResult>(RenderFragment renderFragment, Func<int, TResult
271271 private IReadOnlyList < IRenderedComponentBase < TComponent > > FindComponents < TComponent > ( IRenderedFragmentBase parentComponent , int resultLimit )
272272 where TComponent : IComponent
273273 {
274+ if ( ! Dispatcher . CheckAccess ( ) )
275+ {
276+ return Dispatcher . InvokeAsync ( ( ) => FindComponents < TComponent > ( parentComponent , resultLimit ) ) . GetAwaiter ( ) . GetResult ( ) ;
277+ }
278+
274279 if ( parentComponent is null )
275280 throw new ArgumentNullException ( nameof ( parentComponent ) ) ;
276281
277282 var result = new List < IRenderedComponentBase < TComponent > > ( ) ;
278283 var framesCollection = new RenderTreeFrameDictionary ( ) ;
279-
284+
280285 // the lock is in place to avoid a race condition between
281286 // the dispatchers thread and the test frameworks thread,
282287 // where one will read the current render tree (this method)
283288 // while the other thread (the renderer) updates the
284289 // render tree.
285- lock ( renderTreeAccessLock )
286- {
290+ // lock (renderTreeAccessLock)
291+ // {
287292 FindComponentsInternal ( parentComponent . ComponentId ) ;
288- }
293+ // }
289294
290295 return result ;
291296
@@ -385,4 +390,4 @@ private void AssertNoUnhandledExceptions()
385390 }
386391 }
387392 }
388- }
393+ }
0 commit comments