private static WaitHandle/*!*/[]/*!*/ GetWaitHandles(RubyContext/*!*/ context, RubyArray read, RubyArray write, RubyArray error) {
WaitHandle[] handles = new WaitHandle[
(read != null ? read.Count : 0) +
(write != null ? write.Count : 0) +
(error != null ? error.Count : 0)
];
int i = 0;
if (read != null) {
foreach (object obj in read) {
handles[i++] = ToIo(context, obj).CreateReadWaitHandle();
}
}
if (write != null) {
foreach (object obj in write) {
handles[i++] = ToIo(context, obj).CreateWriteWaitHandle();
}
}
if (error != null) {
foreach (object obj in error) {
handles[i++] = ToIo(context, obj).CreateErrorWaitHandle();
}
}
return handles;
}