PSEyeTexture._ThreadWorker C# (CSharp) Method

_ThreadWorker() private method

private _ThreadWorker ( ) : void
return void
    private void _ThreadWorker()
    {
        for (;;) {
            Thread.Sleep(0);

            // get pixel data from PS Eye
            CLEyeCameraGetFrame(camera_, pixels_handle_.AddrOfPinnedObject(), 500);

            // swap RED and BLUE and reverse the texture vertically
            // (synchronize the following procedure with the main thread)
            mutex_.WaitOne();
            if (isReverse_) {
                for (int i = 0; i < height_; ++i) {
                    for (int j = 0; j < width_; ++j) {
                        int n = i * width_ + j;
                        int m = i * width_ + (width_ - j - 1);
                        pixelsABGR_[n].a = pixels_[m].a;
                        pixelsABGR_[n].r = pixels_[m].b;
                        pixelsABGR_[n].g = pixels_[m].g;
                        pixelsABGR_[n].b = pixels_[m].r;
                    }
                }
            } else {
                int last = width_ * height_ - 1;
                for (int i = 0; i < height_; ++i) {
                    for (int j = 0; j < width_; ++j) {
                        int n = i * width_ + j;
                        int m = i * width_ + (width_ - j - 1);
                        pixelsABGR_[n].a = pixels_[last - m].a;
                        pixelsABGR_[n].r = pixels_[last - m].b;
                        pixelsABGR_[n].g = pixels_[last - m].g;
                        pixelsABGR_[n].b = pixels_[last - m].r;
                    }
                }
            }
            mutex_.ReleaseMutex();
        }
    }