This repository was archived by the owner on May 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Xamarin.Forms.Core.UnitTests Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Concurrent ;
3+ using System . Collections . Generic ;
34using System . Collections . ObjectModel ;
45using System . IO ;
56using System . Reflection ;
@@ -50,7 +51,6 @@ public async Task AddOffUIThread()
5051 // Add an item from a threadpool thread
5152 await Task . Run ( ( ) =>
5253 {
53- var x = Thread . CurrentThread . ManagedThreadId ;
5454 source . Add ( 1 ) ;
5555 countFromThreadPool = moc . Count ;
5656 } ) ;
@@ -232,12 +232,11 @@ class MarshalingTestPlatformServices : IPlatformServices
232232 {
233233 int _threadId ;
234234 bool _running ;
235- BlockingCollection < Action > _todo = new BlockingCollection < Action > ( ) ;
235+ Queue < Action > _todo = new Queue < Action > ( ) ;
236236
237237 public void Stop ( )
238238 {
239239 _running = false ;
240- _todo . CompleteAdding ( ) ;
241240 }
242241
243242 public void Start ( )
@@ -254,7 +253,11 @@ public void Start()
254253 {
255254 try
256255 {
257- _todo . Take ( ) ? . Invoke ( ) ;
256+ Thread . Sleep ( 100 ) ;
257+ while ( _todo . Count > 0 )
258+ {
259+ _todo . Dequeue ( ) . Invoke ( ) ;
260+ }
258261 }
259262 catch ( Exception ex )
260263 {
@@ -268,7 +271,7 @@ public void Start()
268271
269272 public void BeginInvokeOnMainThread ( Action action )
270273 {
271- _todo . Add ( action ) ;
274+ _todo . Enqueue ( action ) ;
272275 }
273276
274277 public OSAppTheme RequestedTheme { get ; }
You can’t perform that action at this time.
0 commit comments