linux-packaging-mono/mcs/tests/test-iter-23.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

43 lines
633 B
C#

using System;
using System.Collections;
using System.Threading;
class X
{
static ManualResetEvent dispose = new ManualResetEvent (false);
static IEnumerable GetIt2 ()
{
yield return Delay ();
yield return 2;
}
static int Delay ()
{
dispose.Set ();
Thread.Sleep (10);
return 1;
}
public static int Main ()
{
var e = GetIt2 ().GetEnumerator ();
ThreadPool.QueueUserWorkItem (l => {
dispose.WaitOne ();
((IDisposable) e).Dispose ();
});
if (!e.MoveNext ())
return 1;
if (e.MoveNext ())
return 2;
Console.WriteLine (e.Current);
if ((int) e.Current != 1)
return 3;
return 0;
}
}