Ejemplo n.º 1
0
        protected virtual void Dispose(bool disposing)
        {
            lock (this)
            {
                if (IsDisposed)
                {
                    return;
                }
                isDisposed = true;

                if (sout != null)
                {
                    sout.WriteLine("TNEmulator.Dispose(" + IsDisposed.ToString() + ")");
                }

                if (disposing)
                {
                    //----------------------------
                    // release managed resources

                    if (currentConnection != null)
                    {
                        if (sout != null)
                        {
                            sout.WriteLine("TNEmulator.Dispose() Disposing of currentConnection");
                        }
                        try
                        {
                            currentConnection.Disconnect();

                            if (apiOnDisconnectDelegate != null)
                            {
                                currentConnection.OnDisconnect -= apiOnDisconnectDelegate;
                            }

                            currentConnection.Dispose();
                        }
                        catch
                        {
                            if (sout != null)
                            {
                                sout.WriteLine("TNEmulator.Dispose() Exception during currentConnection.Dispose");
                            }
                        }
                        currentConnection = null;
                    }

                    OnDisconnect = null;

                    if (sout != null)
                    {
                        sout.WriteLine("TNEmulator.Dispose() Disposing of currentScreenXML");
                    }

                    DisposeOfCurrentScreenXML();

                    if (mObjectState != null)
                    {
                        mObjectState = null;
                    }
                    if (mConnectionConfiguration != null)
                    {
                        mConnectionConfiguration = null;
                    }
                    if (mScreenName != null)
                    {
                        mScreenName = null;
                    }
                }

                //------------------------------
                // release unmanaged resources
            }
        }
Ejemplo n.º 2
0
 public TNEmulator()
 {
     currentScreenXML              = null;
     currentConnection             = null;
     this.mConnectionConfiguration = new ConnectionConfig();
 }