public EventHandle Subscribe(string eventName, Action <Frame> handler)
        {
            var eventHandlers = _handlers.AddOrUpdate(eventName, new ConcurrentDictionary <EventHandle, Action <Frame> >(), (k, v) => v);

            var handle = new EventHandle(eventName);

            eventHandlers.TryAdd(handle, handler);
            return(handle);
        }
        public Task <Frame> GetFrame(string name)
        {
            var promise = new TaskCompletionSource <Frame>();

            EventHandle handle = null;

            handle = Subscribe(name, frame =>
            {
                Unsubscribe(handle);
                promise.TrySetResult(frame);
            });

            if (this._frames.ContainsKey(name))
            {
                Unsubscribe(handle);
                promise.TrySetResult(this._frames[name]);
            }

            return(promise.Task);
        }
        public void Unsubscribe(EventHandle handle)
        {
            var eventHandlers = _handlers.AddOrUpdate(handle.EventName, new ConcurrentDictionary <EventHandle, Action <Frame> >(), (k, v) => v);

            eventHandlers.TryRemove(handle, out Action <Frame> action);
        }