public virtual void Close()
        {
            bool locked = false;

            try
            {
                IOmonitor.IdleForLock(_IOprocessing);
                //
                if (_OutputDevice != null && _OutputDevice.IsInitialized && _OutputDevice.InitializedBy == ParentIDE.Machine)
                {
                    locked = false;
                    if (_OutputDevice.IsLockingRequiredForDispose())
                    {
                        IOmonitor.IdleForLock(_OutputDevice, out locked);
                    }
                    _OutputDevice.Dispose();
                    if (locked)
                    {
                        IOmonitor.Unlock(_OutputDevice);
                    }
                }
                _OutputBuffer.Clear();
            }
            finally
            {
                if (locked)
                {
                    IOmonitor.Unlock(_OutputDevice);
                }
                //
                IOmonitor.Unlock(_IOprocessing);
            }
        }
Exemple #2
0
        public void InitializeIOdeviceInIndividualThread(IOutputDevice outputDevice)
        {
            Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Name            = $"{outputDevice} Output Thread";
                IReinitializeable reinitOutputDevice = outputDevice as IReinitializeable;

                bool locked = false;
                try
                {
                    if (!outputDevice.IsInitialized)
                    {
                        if (outputDevice.IsLockingRequiredForInitialize())
                        {
                            IOmonitor.IdleForLock(outputDevice, out locked);
                        }
                        outputDevice.Initialize(this);
                    }
                    else if (reinitOutputDevice != null)
                    {
                        if (outputDevice.IsLockingRequiredForInitialize() ||
                            outputDevice.IsLockingRequiredForDispose())
                        {
                            IOmonitor.IdleForLock(outputDevice, out locked);
                        }
                        reinitOutputDevice.Reinitialize(this, true);
                    }
                    else
                    {
                        return;
                    }
                }
                finally
                {
                    if (locked)
                    {
                        IOmonitor.Unlock(outputDevice);
                    }
                }

                IOmonitor.IdleWhile(() => outputDevice.IsInitialized);
            });
        }