public void Subscribe(IRandomEventCOMEvents callback) { if (callback == null) throw new ArgumentNullException("callback"); // Note: Make sure multi-threaded concurrency is set. Because timer // events can execute on different threads, the COM callback // calls will freeze if multi-threaded concurrency is NOT set. if (Thread.CurrentThread.GetApartmentState() != ApartmentState.MTA) throw new Exception("Multithreaded object concurrency required"); if (m_callback == null) { m_callback = callback; } else { throw new Exception("Callback is already specified"); } }
public void Unsubscribe() { m_callback = null; }