示例#1
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                ThreadStart method = delegate()
                {
                    DdemlObject.Dispose();
                };

                try 
                {
                    Invoke(method);

                    // Dispose the synchronizer if it was created internally.
                    DdeThread synchronizer = Synchronizer as DdeThread;
                    if (synchronizer != null)
                    {
                        synchronizer.Dispose();
                    }
                }
                catch
                {
                    // Swallow any exception that occurs.
                }
            }
        }
示例#2
0
        /// <summary>
        ///     This contains the implementation to release all resources held by this instance.
        /// </summary>
        /// <param name="disposing">
        ///     True if called by Dispose, false otherwise.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                ThreadStart method = delegate { DdemlObject.Dispose(); };

                try
                {
                    Context.Invoke(method);
                }
                catch
                {
                    // Swallow any exception that occurs.
                }
            }
        }
        /// <summary>
        ///     This removes a transaction filter and stops it from monitoring DDE transactions.
        /// </summary>
        /// <param name="filter">
        ///     The implementation of <c>ITransactionFilter</c> that you want to remove.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     This is thrown when filter is a null reference.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        ///     This is thrown when the filter was not previously added.
        /// </exception>
        /// <remarks>
        ///     <para>
        ///         Transaction filters can be used to intercept the DDEML callback.
        ///     </para>
        ///     <para>
        ///         <note type="caution">
        ///             Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks.
        ///         </note>
        ///     </para>
        /// </remarks>
        public void RemoveTransactionFilter(IDdeTransactionFilter filter)
        {
            ThreadStart method = delegate
            {
                IDdemlTransactionFilter tf = filter == null ? null : new DdemlTransactionFilter(filter);
                DdemlObject.RemoveTransactionFilter(tf);
            };

            try
            {
                Invoke(method);
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(GetType().ToString(), e);
            }
        }
示例#4
0
        /// <summary>
        ///     This terminates all conversations.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        ///     This is thrown when the server is not registered.
        /// </exception>
        /// <exception cref="DdeException">
        ///     This is thrown when the conversations could not be terminated.
        /// </exception>
        public virtual void Disconnect()
        {
            ThreadStart method = delegate { DdemlObject.Disconnect(); };

            try
            {
                Context.Invoke(method);
            }
            catch (DdemlException e)
            {
                throw new DdeException(e);
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(GetType().ToString(), e);
            }
        }
示例#5
0
        /// <overloads>
        ///     <summary>
        ///     </summary>
        /// </overloads>
        /// <summary>
        ///     This resumes the specified conversation.
        /// </summary>
        /// <param name="conversation">
        ///     The conversation to resume.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     This is thrown when conversation is a null reference.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        ///     This is thrown when the conversation is not paused or when the server is not registered.
        /// </exception>
        /// <exception cref="DdeException">
        ///     This is thrown when the conversation could not be resumed.
        /// </exception>
        public virtual void Resume(DdeConversation conversation)
        {
            ThreadStart method = delegate { DdemlObject.Resume(conversation.DdemlObject); };

            try
            {
                Context.Invoke(method);
            }
            catch (DdemlException e)
            {
                throw new DdeException(e);
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(GetType().ToString(), e);
            }
        }
示例#6
0
        /// <summary>
        ///     This notifies all clients that data has changed for the specified topic name and item name pair.
        /// </summary>
        /// <param name="topic">
        ///     A topic name supported by this server.
        /// </param>
        /// <param name="item">
        ///     An item name supported by this server.
        /// </param>
        /// <exception cref="ArgumentException">
        ///     This is thown when topic or item exceeds 255 characters..
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     This is thrown when topic or item is a null reference.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        ///     This is thrown when the server is not registered.
        /// </exception>
        /// <exception cref="DdeException">
        ///     This is thrown when the notification could not be posted.
        /// </exception>
        /// <remarks>
        ///     Use an asterix to indicate that the topic name, item name, or both should be wild.
        /// </remarks>
        public virtual void Advise(string topic, string item)
        {
            ThreadStart method = delegate { DdemlObject.Advise(topic, item); };

            try
            {
                Context.Invoke(method);
            }
            catch (DdemlException e)
            {
                throw new DdeException(e);
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(GetType().ToString(), e);
            }
        }
示例#7
0
        /// <summary>
        /// This starts monitoring the system for DDE activity.
        /// </summary>
        /// <param name="flags">
        /// A bitwise combination of <c>DdeMonitorFlags</c> that indicate what DDE activity will be monitored.
        /// </param>
        public void Start(DdeMonitorFlags flags)
        {
            ThreadStart method = delegate()
            {
                DdemlObject.Start((DdemlMonitorFlags)(int)flags);
            };

            try
            {
                Context.Invoke(method);
            }
            catch (DdemlException e)
            {
                throw new DdeException(e);
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(this.GetType().ToString(), e);
            }
        }
示例#8
0
        /// <summary>
        /// This unregisters the service name.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// This is thrown when the server is not registered.
        /// </exception>
        public virtual void Unregister()
        {
            ThreadStart method = delegate()
            {
                DdemlObject.Unregister();
            };

            try
            {
                Context.Invoke(method);
            }
            catch (DdemlException e)
            {
                throw new DdeException(e);
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(this.GetType().ToString(), e);
            }
        }
示例#9
0
                /// <summary>
                ///     This initializes the context.
                /// </summary>
                /// <exception cref="InvalidOperationException">
                ///     This is thrown when the context is already initialized.
                /// </exception>
                /// <exception cref="DdeException">
                ///     This is thrown when the context could not be initialized.
                /// </exception>
                /// <remarks>
                ///     <para>
                ///         This class must be initialized before it can begin sending and receiving DDE messages.  This happens
                ///         automatically upon its first use by
                ///         a <c>DdeClient</c> or <c>DdeServer</c>.  An application can call <c>Initialize</c> to make the initialization
                ///         process occur immediately.
                ///         This is useful when a calling application expects this class to raise the <c>Register</c> and <c>Unregister</c>
                ///         events or invoke the
                ///         <c>ITransactionFilter.PreFilterTransaction</c> method before being used by a <c>DdeClient</c> or
                ///         <c>DdeServer</c>.
                ///     </para>
                ///     <para>
                ///         If you attempt to use a synchronizer that is not hosted on a thread running a windows message loop an exception
                ///         will be thrown.
                ///     </para>
                ///     <para>
                ///         Explicitly calling this method will allow added <c>ITransactionFilter</c> objects to begin intercepting the
                ///         DDEML callback function.
                ///     </para>
                /// </remarks>
                public void Initialize()
                    {
                        ThreadStart method = delegate
                            {
                                DdemlObject.Initialize();
                                _InstanceId = DdemlObject.InstanceId;
                                _IsInitialized = DdemlObject.IsInitialized;
                            };

                        try
                            {
                                Invoke(method);
                            }
                        catch (DdemlException e)
                            {
                                throw new DdeException(e);
                            }
                        catch (ObjectDisposedException e)
                            {
                                throw new ObjectDisposedException(GetType().ToString(), e);
                            }
                    }
示例#10
0
        /// <overloads>
        /// <summary>
        /// </summary>
        /// </overloads>
        /// <summary>
        /// This terminates the specified conversation.
        /// </summary>
        /// <param name="conversation">
        /// The conversation to terminate.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// This is thrown when conversation is a null reference.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// This is thrown when the server is not registered.
        /// </exception>
        /// <exception cref="DdeException">
        /// This is thrown when the conversation could not be terminated.
        /// </exception>
        public virtual void Disconnect(DdeConversation conversation)
        {
            ThreadStart method = delegate()
            {
                DdemlObject.Disconnect(conversation.DdemlObject);
            };

            try
            {
                Context.Invoke(method);
            }
            catch (DdemlException e)
            {
                throw new DdeException(e);
            }
            catch (ArgumentException e)
            {
                throw e;
            }
            catch (ObjectDisposedException e)
            {
                throw new ObjectDisposedException(this.GetType().ToString(), e);
            }
        }