Voici un exemple plus simple qui ne fonctionne pas
Avez-vous une idée ?
Console.WriteLine("> " + text2);
n'est jamais appelé
Cela bloque au niveau du Join
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
| using (AnonymousPipeServerStream pipeout = new AnonymousPipeServerStream(PipeDirection.Out))
{
using (AnonymousPipeClientStream pipein = new AnonymousPipeClientStream(PipeDirection.In,
pipeout.GetClientHandleAsString()))
{
byte[] res;
Thread t = new Thread(() =>
{
using (MemoryStream x = new MemoryStream())
{
pipein.CopyTo(x);
res = x.ToArray();
string text2 = Encoding.UTF8.GetString(res);
Console.WriteLine("> " + text2);
}
});
t.Start();
string text = "hello !";
using (MemoryStream x = new MemoryStream(Encoding.UTF8.GetBytes(text)))
{
x.CopyTo(pipeout);
}
t.Join();
}
} |
Partager