我需要在同一進程中有一個匿名管道,以允許兩個庫之間基於流的異步通信。訪問在單個進程中使用AnonymousPipeStreams時被拒絕
一切工作,直到我調用Stream.Read() - 我得到一個UnauthorizedAccessException - 訪問路徑被拒絕。有任何想法嗎?
using (var pipeServer = new AnonymousPipeServerStream(PipeDirection.Out))
using (var pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeServer.SafePipeHandle))
{
// External lib should close server pipe when it's done
archFile.ExtractionFinished += (sender, args) => pipeServer.Close();
archFile.BeginExtractFile(archFileName, pipeServer);
var buf = new byte[1000];
int read;
while ((read = pipeClient.Read(buf, 0, buf.Length)) > 0)
{ ... }
}
你應該對妮可的回答發表評論,而不是創建一個新的。 – 2012-10-10 19:52:44