Skip to content

Instantly share code, notes, and snippets.

@sdether
Created January 12, 2012 07:05
Show Gist options
  • Select an option

  • Save sdether/1599137 to your computer and use it in GitHub Desktop.

Select an option

Save sdether/1599137 to your computer and use it in GitHub Desktop.
class Producer {
public static IEnumerator Coroutine(int[,] source, Coordinator<int[]> coordinator) {
Console.WriteLine("producer started");
for(var i = 0; i < source.GetLength(0); i++) {
coordinator.State = new int[source.GetLength(1)];
for(var j = 0; j < source.GetLength(1); j++) {
coordinator.State[j] = source[i, j];
Console.WriteLine("read {0} from [{1},{2}]", source[i, j], i, j);
}
Console.WriteLine("yielding to consumer");
yield return null;
}
coordinator.State = new int[0];
Console.WriteLine("producer finished");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment