Exemplo n.º 1
0
        /// <summary>
        /// Creates a native subscription
        /// </summary>
        /// <param name="observable"></param>
        /// <param name="observer"></param>
        public NativeSubscription(NativeObservable observable, IObserver <NativeData> observer)
        {
            this.observer = observer;

            lock (this.sync)
            {
                this.pinnedDelegate = new NativeMethods.NativeCallback(HandleNativeEvent);
                NativeMethods.RegisterNativeCallback(this.pinnedDelegate);
            }
        }
Exemplo n.º 2
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    this.pinnedDelegate = null;
                }

                lock (this.sync)
                {
                    NativeMethods.UnregisterNativeCallback();
                }

                disposedValue = true;
            }
        }