Exemplo n.º 1
0
 void StartUpdating(WaitHandle waitHandle, KinectBaseImageStream stream)
 {
     var task = waitHandle.WaitTask(Timeout.Infinite);
     task.ToObservable()
         .ObserveOnDispatcher()
         .SelectMany(_ => Observable.Using(
             () => stream.GetFrame(waitHandle.Handle)
                 , frame => Observable.Return(frame))
         )
         .Where(frame => frame != null)
         .Subscribe(
         frame => _depthSource.WritePixels(
                 new Int32Rect(0, 0, frame.Width, frame.Height),
                 frame.Ptr,
                 frame.BufferSize,
                 frame.Pitch)
         , ex => {
             Console.WriteLine(ex);
             StartUpdating(waitHandle, stream);
         }
         , () => StartUpdating(waitHandle, stream)
         )
         ;
 }