[Mono-dev] System.Diagnostics.Process thoughts
Mesut Özkan
mesutozkan at live.com
Wed Oct 29 05:02:02 EDT 2008
Hi... I have two problems one about unix process. I use GTK# unix programs
so list of process and check each of process responding in using Mono.Unix
reference
i did this program in Windows C# using System.Diagnoctics reference
how can i decode C# to GTK# - System.Diagnoctics to Mono.Unix ???
my C# code ///////
using System;
using System.Text;
using System.Diagnostics;
using System.Threading;
namespace Son
{
class Program
{
/*
Main
*/
static void Main(string[] args)
{
Thread t = new Thread(ThreadProcess);
t.Start();
}
/*
Thread Function
*/
public static void ThreadProcess()
{
int i = 0;
while (true)
{
i++;
IsProcRunning("cmd",false);
Console.WriteLine("Thread : {0}", i.ToString());
Thread.Sleep(1000);
}
}
/*
Not Responding Control
*/
public static bool IsProcRunning(string procName, bool killIt)
{
bool ok = false;
Process[] procs = Process.GetProcessesByName("cmd");
try
{
if (procs[0].Responding)
{
Console.WriteLine(procs[0] + " is responding");
ok = true;
}
else
{
Console.WriteLine(procs[0] + " is not responding");
}
}
catch
{
Console.WriteLine(procName + " is not running");
}
if (killIt)
{
try
{
if (procs[0].Responding)
{
procs[0].CloseMainWindow();
}
else
{
////Kapat ve Ac
//procs[0].Kill();
//procs[0].Start();
}
}
catch
{
Console.WriteLine("Could Not Find the " + procName + "
Process");
}
}
return ok;
}
}
}
this program controlling cmd.exe and giving intro
i can compile this program in mono developer in linux
but my exe not working in solaris
my research was tell me i should use Mono.Unix reference
but i couldnt...
And my second problem ,i can see process use of unix terminal in Status file
but when i was opened status file,i can see only binary code not TXT . how
can i see status.txt this file
have a any property option for save option txt/c/h/ like this ?
--
View this message in context: http://www.nabble.com/System.Diagnostics.Process-thoughts-tp10163089p20223075.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list
mailing list