Results 1 to 8 of 8
  1. #1

    Default Output text to another console window in c#


    Code:
    public static void workerThread()
            {
                ProcessStartInfo exec = new ProcessStartInfo("cmd.exe");
                exec.RedirectStandardInput = true;
                exec.RedirectStandardOutput = true;
                exec.RedirectStandardError = true;
                exec.UseShellExecute = false;    
                Process p = Process.Start(exec);
                System.IO.StreamWriter streamWriter = p.StandardInput;
                System.IO.StreamReader streamReader = p.StandardOutput;
    
                streamWriter.WriteLine("thread started");             
    
                for (int i = 0; i < 10; i++)
                {
                       streamWriter.WriteLine("Time is..{0}",DateTime.Now.TimeOfDay.ToString());
                   
                       Thread.Sleep(500);
                }
                streamWriter.WriteLine("Thread Closing");
                streamReader.Close();
    
            }
    I'm having a hard time on this one. It seems it doesn't show the console window with text in it.

    Is there a way to sort this out?

    What I want is to output a certain text in another console window just for monitoring of process resources.




    tnx,
    ta3

  2. #2
    Quote Originally Posted by ta3 View Post
    Code:
    public static void workerThread()
            {
                ProcessStartInfo exec = new ProcessStartInfo("cmd.exe");
                exec.RedirectStandardInput = true;
                exec.RedirectStandardOutput = true;
                exec.RedirectStandardError = true;
                exec.UseShellExecute = false;    
                Process p = Process.Start(exec);
                System.IO.StreamWriter streamWriter = p.StandardInput;
                System.IO.StreamReader streamReader = p.StandardOutput;
    
                streamWriter.WriteLine("thread started");             
    
                for (int i = 0; i < 10; i++)
                {
                       streamWriter.WriteLine("Time is..{0}",DateTime.Now.TimeOfDay.ToString());
                   
                       Thread.Sleep(500);
                }
                streamWriter.WriteLine("Thread Closing");
                streamReader.Close();
    
            }
    I'm having a hard time on this one. It seems it doesn't show the console window with text in it.

    Is there a way to sort this out?

    What I want is to output a certain text in another console window just for monitoring of process resources.




    tnx,
    ta3
    Why not use logging tools like log4net?

  3. #3
    Thanks eax. I'll look for that one.

  4. #4
    how about exec.UseShellExecute = true; ?

  5. #5
    I tried that one but to no avail...it throws an error.

  6. #6
    what about SendMessage PostMessage API?

    i dont know if its gonna work in console though.. it works on winApps.

    if this is for logging.. you'd probably want to just write a file yourself.

  7. #7
    Well here's the thing. I have a Console Application in which it monitors a certain application and I create another thread to get its process resources every 10 seconds such as memory usage, thread count..etc..and log it to a file...well I already made that up but the thing is every time I log the process resources I want to output it in another console window so that I would not open the log file just to see data.

  8. #8
    sounds like .Net remoting you might want to check that out

  9.    Advertisement

Similar Threads

 
  1. Magtxt Messenger - Free text to all networks for Windows
    By bangonkali in forum Windows Software
    Replies: 21
    Last Post: 01-02-2016, 04:19 PM
  2. how to delete undeletable file in windows xp?
    By jhiameill in forum Windows Software
    Replies: 8
    Last Post: 08-27-2013, 04:16 AM
  3. how to hide the drives in my computer in windows xp?
    By jhiameill in forum Windows Software
    Replies: 0
    Last Post: 04-26-2013, 01:34 PM
  4. how to copy wireless settings in windows xp
    By samygs in forum Windows Software
    Replies: 0
    Last Post: 04-29-2011, 07:15 PM
  5. how to use the poledit in windows 98?
    By AMD_earl in forum Software & Games (Old)
    Replies: 2
    Last Post: 08-17-2006, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top