Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     using (CommandLine command = new TailCommandLine(args))
       {
     CommandLineBootstrap.Start(command);
       }
 }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     using (CommandLine command = new TailCommandLine(args))
     {
         CommandLineBootstrap.Start(command);
     }
 }
Ejemplo n.º 3
0
        private void OnTailButtonClick(object sender, RoutedEventArgs e)
        {
            if (btnTail.Content.ToString() == TailCommand)
              {
            if (string.IsNullOrEmpty(tbFileName.Text))
            {
              MessageBox.Show(this, "Please specify a file for tailing.", this.Title,
            MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
              return;
            }

            btnTail.Content = CancelCommand;
            tbFileName.IsEnabled = false;
            btnOpenFile.IsEnabled = false;
            tbFileData.Document.Blocks.Clear();

            try
            {
              string[] args = new string[] {
            @"-F",
            tbFileName.Text
              };

              tail = new TailCommandLine(args);
              tail.CommandLineException += new EventHandler<CommandLineExceptionEventArgs>(OnCommandLineException);
              tail.CommandLineDataChanged += new EventHandler<CommandLineDataChangedEventArgs>(OnCommandLineDataChanged);

              ThreadPool.QueueUserWorkItem((WaitCallback)TailExecuter, tail);
            }
            catch (Exception ex)
            {
              MessageBox.Show(this, ex.Message, this.Title,
            MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
              }
              else
              {
            btnTail.Content = TailCommand;
            tbFileName.IsEnabled = true;
            btnOpenFile.IsEnabled = true;

            try
            {
              if (tail != null)
              {
            tail.CommandLineException -= new EventHandler<CommandLineExceptionEventArgs>(OnCommandLineException);
            tail.CommandLineDataChanged -= new EventHandler<CommandLineDataChangedEventArgs>(OnCommandLineDataChanged);
            tail.Terminate();
            tail.Dispose();
            tail = null;
              }
            }
            catch (Exception ex)
            {
              MessageBox.Show(this, ex.Message, this.Title,
            MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
              }
        }