Process.StandardOutput.EndOfStream bloquant à la lecture
Bonjour,
j'ai développé une petite application en mode console. Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Log(String Text)
{
String CurrentDateTime;
CurrentDateTime = String.Format("{0:d2}/{1:d2}/{2:d4} {3:d2}:{4:d2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year, DateTime.Now.Hour, DateTime.Now.Minute);
Console.WriteLine(CurrentDateTime + " - " + Text.TrimEnd() + Environment.NewLine);
}
static void Main(string[] args)
{
int i;
String RootFile ;
ClassFTPServer server;
RootFile = System.IO.Directory.GetCurrentDirectory();
if (args.Length > 1)
{
for (i = 0; i < args.Length; i++)
{
if (args[i].ToLower() == "-root")
{
i++;
RootFile = args[i];
}
}
}
server = new ClassFTPServer(RootFile);
server.OnLog = Log;
server.Start();
Log("Server terminate");
}
}
} |
Je fais une interface graphique qui va lancer l'application console.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| private void ReadLogFromServer()
{
String Line;
while (ServerProcessus.StandardOutput.EndOfStream == false)
{
Line = ServerProcessus.StandardOutput.ReadLine();
if (Line == null)
{
break;
}
textBoxLog.AppendText(Line + Environment.NewLine);
Application.DoEvents();
}
} |
Si je teste mon deuxième code avec n'importe qu'elle application console ça fonctionne (même une que j'écris à la main pour tester)
Mais avec mon premier programme, Process.StandardOutput.EndOfStream bloque quand il n'y a plus de données.
D'où vient le problème ?
J'ai chercher sur Internet mais je n'ai trouvé aucune information. Je pense que le problème vient de mon premier programme mais je ne vois pas où.
Merci