Пример #1
0
 public void Dispose()
 {
     if (_handleSessionLifetime)
     {
         if (_instrumentSession != null)
         {
             ((IDisposable)(_instrumentSession)).Dispose();
             _instrumentSession = null;
         }
     }
     _writer = null;
     GC.SuppressFinalize(this);
 }
Пример #2
0
        /// <summary>
        /// This task will use the MessageBasedSession passed in.  This task can either the MessageBasedSession or leave it open for the caller to close.
        /// </summary>
        /// <param name="session">MessageBasedSession used by this task.</param>
        /// <param name="taskHandlesSessionLifetime">If true, the task will close session when the task is disposed. If false, the caller is responsible for closing session.</param>
        public SetChannel_A(MessageBasedSession session, bool taskHandlesSessionLifetime)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            _instrumentSession         = session;
            _instrumentSession.Timeout = 2000;
            _instrumentSession.TerminationCharacterEnabled = true;
            _instrumentSession.TerminationCharacter        = 10;

            // The caller can control the VISA session lifetime by passing in false for taskHandlesSessionLifetime.  If taskHandlesSessionLifetime
            // is true, then the VISA session will be closed when the caller disposes this task.
            _handleSessionLifetime = taskHandlesSessionLifetime;

            // The MessageBasedSessionWriter is used to write formatted data to the instrument
            _writer = new MessageBasedSessionWriter(_instrumentSession);
        }