Dispose() 보호된 메소드

Releases the unmanaged resources used by the T:System.IO.Stream and optionally releases the managed resources.
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
리턴 void
예제 #1
0
        public bool StartShellStream()
        {
            if (!ConnectSSH ())	return false;

            ManualResetEvent started = new ManualResetEvent(false);
            ShellStreamTask = new Task( () =>
            {
                try
                {
                    WriteLine("Starting terminal: Emulation = {0}",Host.TerminalEmulation);

                    shellStream = sshClient.CreateShellStream(Host.TerminalEmulation,(uint)Host.TerminalCols,(uint)Host.TerminalRows,0,0,4096);

                    shellStream.DataReceived += (object sender, ShellDataEventArgs e) =>
                    {
                        Write(Encoding.UTF8.GetString(e.Data,0,e.Data.Length));
                    };

                    shellStream.ErrorOccurred+= (object sender, ExceptionEventArgs e) =>
                    {
                        WriteLine(e.Exception.Message);
                        keepShellAlive.Set();
                    };

                    if (!String.IsNullOrEmpty(Host.WorkingDir))
                    {
                        Write("Changing dir: {0}...",Host.WorkingDir);
                        shellStream.WriteLine(String.Format("cd {0}\r\n",Host.WorkingDir));
                    }
                    started.Set();
                    keepShellAlive.Reset();
                    keepShellAlive.WaitOne();

                    WriteLine("\r\n*** Console Stream End");
                }
                catch (Exception ex)
                {
                    WriteLine("\r\n*** Console Stream Error: {0}",ex.Message);
                }
                finally
                {
                    shellStream.Dispose();
                    shellStream = null;
                }

            });
            ShellStreamTask.Start();
            return started.WaitOne(5000);
        }