a3fa
![]() |
|
|
|
|
|||||||
| Userland Programming & Scripting C, Shell, Perl, Sed & Awk |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hello, I'm launching top process in Mono (I know right - herecy) and redirecting it's output to a string (then the parsing will begin). Problem is, that it runs once and quits.
In Linux this code runs flawlessly: http://i.imgur.com/hrB85.jpg Code:
using System;
using System.Diagnostics;
namespace top2
{
class Program
{
static int Main(string[] args)
{
var proc = new ProcessStartInfo("/usr/bin/top", "-b")
{
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true
};
using(Process p = Process.Start(proc))
{
try
{
while(p.StandardOutput.Peek() > 0)
{
string line = p.StandardOutput.ReadLine();
//string line2 = p.StandardError.ReadLine() ?? "";
//Console.WriteLine(line);
//if(line2.Length > 0) Console.WriteLine("error: " + line2);
if(line.Contains("Cpu(s):"))
{
Console.WriteLine(line);
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
return 0;
}
}
}
Why why why? Last edited by fryshke; August 5th, 2012 at 19:14. |
|
#3
|
|||
|
|||
|
Thanks, -d 9999 helped, after 9999 times, I just start another process.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| mono-sgen | ArsenShnurkov | Porting New Software | 6 | January 22nd, 2013 22:40 |
| deleted content of rc.conf, now machine continuously reboots | Vitamin | General | 11 | February 1st, 2012 09:08 |
| [Solved] Mono Winforms | timmmay | Userland Programming & Scripting | 2 | September 17th, 2011 23:49 |
| [Solved] Mono VGA driver | jbt302 | X.Org | 2 | October 19th, 2009 18:35 |
| [Solved] mono | tim-m89 | Installation and Maintenance of FreeBSD Ports or Packages | 8 | June 6th, 2009 08:12 |