Hello,
> I wanted to use yield (like Miguel did it in HttpApplication), but I need to
> lock by data. Is this not allowed?
>
> static object lockit = new Object();
>
> public static IEnumerable GetData()
> {
> lock (lockit)
> {
> for (int i = 0; i < 10; i++)
> yield return true;
> }
> }
>
> I am getting this error (with Mono, it works with MS.Net):
This is a bug in the compiler. But even with the bug fixed the code
above will not work in the way you think it would.
The lock will be taken the first time, and released on the first yield,
and will not be taken again when the method resumes execution (although
Monitor.Exit will be called repeated times).
Basically yield and lock dont mix.
Miguel
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list