I have MainForm
class and some Engine
class for camera control. In Engine
class, I have some Camera
object, which is part of SDK from camera producer.
This Camera
has available OnNewFrame
event, so I'll initialize:
camera.OnNewFrame += frameAcquired;
frameAcquired
is also member of Engine class.
private void frameAcquired(object sender, EventArgs e)
{
/* this event should periodically raise after ~17ms,
but sometimes it hangs for a short time
(when I overloads main thread) */
}
The Engine
object is a member of MainForm
class. Here I am displaying images from camera and doing some other graphics stuff. The problem is that MainForm
thread sometimes hangs for a very short time. It's not so critical for displaying, but it is for camera.OnNewFrame
event (I'm working with 60 fps), as this is also delayed because of main thread delay.
Is it possible to ensure some way, that Engine
object (or Camera
object in Engine
) will raise event's from it's own thread, not from main thread? Other words, ensure that this event raises in rate which SDK producer has set, not dependent on my main thread.