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 1
1
using System ;
2
2
using System . Collections . Concurrent ;
3
+ using System . Collections . Generic ;
3
4
using System . Collections . ObjectModel ;
4
5
using System . IO ;
5
6
using System . Reflection ;
@@ -50,7 +51,6 @@ public async Task AddOffUIThread()
50
51
// Add an item from a threadpool thread
51
52
await Task . Run ( ( ) =>
52
53
{
53
- var x = Thread . CurrentThread . ManagedThreadId ;
54
54
source . Add ( 1 ) ;
55
55
countFromThreadPool = moc . Count ;
56
56
} ) ;
@@ -232,12 +232,11 @@ class MarshalingTestPlatformServices : IPlatformServices
232
232
{
233
233
int _threadId ;
234
234
bool _running ;
235
- BlockingCollection < Action > _todo = new BlockingCollection < Action > ( ) ;
235
+ Queue < Action > _todo = new Queue < Action > ( ) ;
236
236
237
237
public void Stop ( )
238
238
{
239
239
_running = false ;
240
- _todo . CompleteAdding ( ) ;
241
240
}
242
241
243
242
public void Start ( )
@@ -254,7 +253,11 @@ public void Start()
254
253
{
255
254
try
256
255
{
257
- _todo . Take ( ) ? . Invoke ( ) ;
256
+ Thread . Sleep ( 100 ) ;
257
+ while ( _todo . Count > 0 )
258
+ {
259
+ _todo . Dequeue ( ) . Invoke ( ) ;
260
+ }
258
261
}
259
262
catch ( Exception ex )
260
263
{
@@ -268,7 +271,7 @@ public void Start()
268
271
269
272
public void BeginInvokeOnMainThread ( Action action )
270
273
{
271
- _todo . Add ( action ) ;
274
+ _todo . Enqueue ( action ) ;
272
275
}
273
276
274
277
public OSAppTheme RequestedTheme { get ; }
You can’t perform that action at this time.
0 commit comments