명명 된 파이프를 통해 프로세스로 업데이트를 푸시하려고 시도하고 있지만 그렇게하면 내 프로세스 루프가 이음매가되어 while ((line = sr.ReadLine()) != null)
에서 멈추게됩니다. 이것이 명명 된 파이프에 대한 첫 번째 진입이기 때문에 무엇이 잘못 될지에 대해 약간 신비가 있습니다.명명 된 파이프가 실을 ?니 다?
void RefreshThread()
{
using (NamedPipeServerStream pipeStream = new NamedPipeServerStream("processPipe", PipeDirection.In))
{
pipeStream.WaitForConnection();
using (StreamReader sr = new StreamReader(pipeStream))
{
for (; ;)
{
if (StopThread == true)
{
StopThread = false;
return; // exit loop and terminate the thread
}
// push update for heartbeat
int HeartbeatHandle = ItemDictionary["Info.Heartbeat"];
int HeartbeatValue = (int)Config.Items[HeartbeatHandle].Value;
Config.Items[HeartbeatHandle].Value = ++HeartbeatValue;
SetItemValue(HeartbeatHandle, HeartbeatValue, (short)0xC0, DateTime.Now);
string line = null;
while ((line = sr.ReadLine()) != null)
{
// line is in the format: item, value, timestamp
string[] parts = line.Split(',');
// push update and store value in item cache
int handle = ItemDictionary[parts[0]];
object value = parts[1];
Config.Items[handle].Value = int.Parse(value);
DateTime timestamp = DateTime.FromBinary(long.Parse(parts[2]));
SetItemValue(handle, value, (short)0xC0, timestamp);
}
Thread.Sleep(500);
}
}
}
}
이 문제에 대한 해결책은 Queue<string>