internal void AddOrRemoveEvent(Action a) { if (_context != null) { _context.Post(new SendOrPostCallback((o) => { a.Invoke(); }), null); } else { // Note: We add or remove events on the callback thread, since this is where events // are fired. Also, we use 'BeginInvoke' to avoid deadlocks if the user attempts to // hook up an event from within another event handler (example: Hook up ImageReady // from within DeviceAdded) _callback.BeginInvoke(a); } }
internal void BeginInvoke(Delegate d, params object[] args) { _worker.BeginInvoke(d, args); }