I have a legacy class which I would like to consume in a more convenient way.
class Camera
{
void RequestCapture();
public delegate void ReadResultEventHandler(ControllerProxy sender, ReadResult readResult);
public event ReadResultEventHandler OnReadResult;
}
The class manages a camera that takes pictures. It works by:
- Invoking the RequestCapture method
- Awaiting for the OnReadResult to be raised (obviously, you need to subscribe to this event in order to get the captured data)
The operation is asynchronous. The RequestCapture is a fire-and-forget operation (fast!) operation. After some seconds, the event will raise.
I would like to consume it either like as regular Task or as an IObservable<ReadResult> but I'm quite lost, since it doesn't adapt to the Async Pattern, and I have never used a class like this.