110,533
社区成员
发帖
与我相关
我的任务
分享
view plain
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Testing in :" + DateTime.Now.ToString());
System.Threading.Thread.Sleep(50);
}
}
static void Main(string[] args)
{
StreamReader sr;
ProcessStartInfo s = new ProcessStartInfo();
s.RedirectStandardInput = true;
s.RedirectStandardOutput = true;
s.UseShellExecute = false;
s.FileName = @"d:\OutputRepeat.exe";
Process p = Process.Start(s);
sr = p.StandardOutput;
while (!sr.EndOfStream)
{
string str = sr.ReadLine();
Console.WriteLine(str);
}
p.WaitForExit();
p.Close();
}
static void Main(string[] args)
{
while (true)
{
Console.Write("Testing in :" + DateTime.Now.ToString());
System.Threading.Thread.Sleep(50);
}
}
static void Main(string[] args)
{
StreamReader sr;
ProcessStartInfo s = new ProcessStartInfo();
s.RedirectStandardInput = true;
s.RedirectStandardOutput = true;
s.UseShellExecute = false;
s.FileName = @"E:\CSharp\OutputRepeat\bin\Release\OutputRepeat.exe";
Process p = Process.Start(s);
sr = p.StandardOutput;
while (!sr.EndOfStream)
{
char[] bs = new char[16];
int i = sr.Read(bs, 0, 16);
foreach (char o in bs)
{
Console.Write(o);
}
}
p.WaitForExit();
p.Close();
}
private static String FilePath = Application.StartupPath + "\\DigitalSwitching.exe";
private void SignalMonitor_Load(object sender, EventArgs e)
{
using (Process process=new System.Diagnostics.Process())
{
process.StartInfo.FileName = FilePath;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
}
}
程序启动后,通过点击按钮弹出一个Form,Form中有一个多行文本显示Console读取到的数据,点击后程序又重新运行显示两个进程这怎么解决??