File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Threading ;
23using NUnit . Framework ;
34using Python . Runtime ;
45
@@ -337,9 +338,12 @@ public void TestThread()
337338 //add function to the scope
338339 //can be call many times, more efficient than ast
339340 ps . Exec (
341+ "import clr\n " +
342+ "from System.Threading import Thread\n " +
340343 "def update():\n " +
341344 " global res, th_cnt\n " +
342345 " res += bb + 1\n " +
346+ " Thread.MemoryBarrier()\n " +
343347 " th_cnt += 1\n "
344348 ) ;
345349 }
@@ -364,8 +368,9 @@ public void TestThread()
364368 {
365369 cnt = ps . Get < int > ( "th_cnt" ) ;
366370 }
367- System . Threading . Thread . Sleep ( 10 ) ;
371+ Thread . Sleep ( 10 ) ;
368372 }
373+ Thread . MemoryBarrier ( ) ;
369374 using ( Py . GIL ( ) )
370375 {
371376 var result = ps . Get < int > ( "res" ) ;
You can’t perform that action at this time.
0 commit comments