private void VerifyBytesToRead(ReadMethodDelegate readMethod, int bufferSize, bool sendNewLine) { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { SerialPortProperties serPortProp = new SerialPortProperties(); int numNewLineBytes = 0; serPortProp.SetAllPropertiesToOpenDefaults(); serPortProp.SetProperty("PortName", TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); com1.Open(); com2.Open(); com2.Write(new byte[bufferSize], 0, bufferSize); if (sendNewLine) { com2.Write(com2.NewLine); numNewLineBytes = com2.Encoding.GetByteCount(com2.NewLine.ToCharArray()); } while (bufferSize + numNewLineBytes > com1.BytesToRead) { Thread.Sleep(10); } readMethod(com1, bufferSize + numNewLineBytes); serPortProp.VerifyPropertiesAndPrint(com1); } }
private void VerifyParityReplaceByte(SerialPort com1, SerialPort com2, ReadMethodDelegate readMethod, bool newLine) { byte[] bytesToWrite = new byte[s_numRndBytesPairty]; char[] expectedChars = new char[s_numRndBytesPairty]; Random rndGen = new Random(); int parityErrorIndex = rndGen.Next(0, s_numRndBytesPairty - 1); byte newLineByte = (byte)com1.NewLine[0]; com1.Parity = Parity.Space; com1.DataBits = 7; com1.ReadTimeout = 500; //Genrate random characters without an parity error for (int i = 0; i < bytesToWrite.Length; i++) { byte randByte; do { randByte = (byte)rndGen.Next(0, 128); } while (randByte == newLineByte); bytesToWrite[i] = randByte; expectedChars[i] = (char)randByte; } bytesToWrite[parityErrorIndex] |= (byte)0x80; expectedChars[parityErrorIndex] = (char)com1.ParityReplace; VerifyRead(com1, com2, bytesToWrite, expectedChars, readMethod, newLine); }
public bool VerifyDefaultTimeout(ReadMethodDelegate readMethod) { SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName); bool retValue = true; com1.Open(); if (!com2.IsOpen) { com2.Open(); } com1.BaseStream.WriteTimeout = 1; retValue &= Eval(-1 == com1.BaseStream.ReadTimeout, String.Format("Err_70217shpza!!! Expected ReadTimeout to be {0} actaul {1}", -1, com1.BaseStream.ReadTimeout)); retValue &= VerifyLongTimeout(readMethod, com1, com2); if (com1.IsOpen) { com1.Close(); } if (com2.IsOpen) { com2.Close(); } return(retValue); }
public bool VerifyZeroTimeout(SerialPort com, ReadMethodDelegate readMethod) { SerialPortProperties serPortProp = new SerialPortProperties(); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); bool retValue = true; int actualTime = 0; serPortProp.SetAllPropertiesToOpenDefaults(); serPortProp.SetProperty("PortName", TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); serPortProp.SetProperty("ReadTimeout", 0); serPortProp.SetProperty("WriteTimeout", 1000); com.WriteTimeout = 1000; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest; sw.Start(); readMethod(com); sw.Stop(); if (MAX_ACCEPTABLE_WARMUP_ZERO_TIMEOUT < sw.ElapsedMilliseconds) { Console.WriteLine("Err_2570ajdlkj!!! Read Method {0} timed out in {1}ms expected something less then {2}ms", readMethod.Method.Name, sw.ElapsedMilliseconds, MAX_ACCEPTABLE_WARMUP_ZERO_TIMEOUT); retValue = false; } sw.Reset(); for (int i = 0; i < NUM_TRYS; i++) { sw.Start(); readMethod(com); sw.Stop(); actualTime += (int)sw.ElapsedMilliseconds; sw.Reset(); } System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal; actualTime /= NUM_TRYS; if (MAX_ACCEPTABLE_ZERO_TIMEOUT < actualTime) { Console.WriteLine("ERROR!!! Read Method {0} timed out in {1}ms expected something less then {2}ms", readMethod.Method.Name, actualTime, MAX_ACCEPTABLE_ZERO_TIMEOUT); retValue = false; } retValue &= serPortProp.VerifyPropertiesAndPrint(com); com.ReadTimeout = 0; if (com.IsOpen) { com.Close(); } return(retValue); }
public bool VerifyInfiniteTimeout(ReadMethodDelegate readMethod, bool setInfiniteTimeout) { SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName); ReadDelegateThread readThread = new ReadDelegateThread(com1, readMethod); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(readThread.CallRead)); SerialPortProperties serPortProp = new SerialPortProperties(); bool retValue = true; serPortProp.SetAllPropertiesToOpenDefaults(); serPortProp.SetProperty("PortName", TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); serPortProp.SetProperty("WriteTimeout", 10); com1.WriteTimeout = 10; com1.Open(); if (!com2.IsOpen) { com2.Open(); } if (setInfiniteTimeout) { com1.ReadTimeout = 500; com1.ReadTimeout = SerialPort.InfiniteTimeout; } t.Start(); System.Threading.Thread.Sleep(DEFAULT_WAIT_INFINITE_TIMEOUT); if (!t.IsAlive) { Console.WriteLine("ERROR!!! {0} terminated with infinite timeout", readMethod.Method.Name); retValue = false; } retValue &= serPortProp.VerifyPropertiesAndPrint(com1); com2.WriteLine(String.Empty); while (t.IsAlive) { System.Threading.Thread.Sleep(10); } if (com1.IsOpen) { com1.Close(); } if (com2.IsOpen) { com2.Close(); } return(retValue); }
private bool VerifyParityReplaceByte(int parityReplace, ReadMethodDelegate readMethod, bool newLine) { bool retValue = true; retValue &= VerifyParityReplaceByteBeforeOpen(parityReplace, readMethod, newLine); retValue &= VerifyParityReplaceByteAfterOpen(parityReplace, readMethod, newLine); return(retValue); }
private void VerifyZeroTimeoutAfterOpen(ReadMethodDelegate readMethod) { using (SerialPort com = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { com.Open(); com.ReadTimeout = 0; VerifyZeroTimeout(com, readMethod); } }
private void VerifyParityReplaceByteAfterOpen(int parityReplace, ReadMethodDelegate readMethod, bool newLine) { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { com1.Open(); com2.Open(); com1.ParityReplace = (byte)parityReplace; VerifyParityReplaceByte(com1, com2, readMethod, newLine); } }
public bool VerifyZeroTimeoutAfterOpen(ReadMethodDelegate readMethod) { SerialPort com = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); bool retValue = true; com.Open(); com.ReadTimeout = 0; retValue &= VerifyZeroTimeout(com, readMethod); return(retValue); }
private bool VerifyTimeout(ReadMethodDelegate readMethod, Stream stream) { System.Diagnostics.Stopwatch timer = new Stopwatch(); int expectedTime = stream.ReadTimeout; int actualTime; double percentageDifference; bool retValue = true; //Warmup the read method. When called for the first time the read method seems to take much longer then subsequent calls timer.Start(); try { readMethod(stream); } catch (TimeoutException) { } timer.Stop(); actualTime = (int)timer.ElapsedMilliseconds; percentageDifference = System.Math.Abs((expectedTime - actualTime) / (double)expectedTime); //Verify that the percentage difference between the expected and actual timeout is less then maxPercentageDifference retValue &= Eval(percentageDifference <= MAX_ACCEPTABLE_WARMUP_PERCENTAGE_DIFFERENCE, String.Format("Err_88558amuph!!!: The read method timedout in {0} expected {1} percentage difference: {2} when called for the first time", actualTime, expectedTime, percentageDifference)); actualTime = 0; timer.Reset(); //Perform the actual test verifying that the read method times out in approximately ReadTime milliseconds System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest; for (int i = 0; i < NUM_TRYS; i++) { timer.Start(); try { readMethod(stream); } catch (TimeoutException) { } timer.Stop(); actualTime += (int)timer.ElapsedMilliseconds; timer.Reset(); } System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal; actualTime /= NUM_TRYS; percentageDifference = System.Math.Abs((expectedTime - actualTime) / (double)expectedTime); //Verify that the percentage difference between the expected and actual timeout is less then maxPercentageDifference retValue &= Eval(percentageDifference <= MAX_ACCEPTABLE_PERCENTAGE_DIFFERENCE, String.Format("Err_56485ahpbz!!!: The read method timedout in {0} expected {1} percentage difference: {2}", actualTime, expectedTime, percentageDifference)); return(retValue); }
private bool Verify0Timeout(ReadMethodDelegate readMethod, Stream stream) { System.Diagnostics.Stopwatch timer = new Stopwatch(); int expectedTime = stream.ReadTimeout; int actualTime; bool retValue = true; //Warmup the read method. When called for the first time the read method seems to take much longer then subsequent calls timer.Start(); try { readMethod(stream); } catch (TimeoutException) { } timer.Stop(); actualTime = (int)timer.ElapsedMilliseconds; //Verify that the time the method took to timeout is less then the maximum acceptable time retValue &= Eval(actualTime <= MAX_ACCEPTABLE_WARMUP_ZERO_TIMEOUT, String.Format("Err_277a0ahpsb!!!: With a timeout of 0 the read method timedout in {0} expected something less then {1} when called for the first time", actualTime, MAX_ACCEPTABLE_WARMUP_ZERO_TIMEOUT)); actualTime = 0; timer.Reset(); //Perform the actual test verifying that the read method times out in approximately ReadTime milliseconds System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest; for (int i = 0; i < NUM_TRYS; i++) { timer.Start(); try { readMethod(stream); } catch (TimeoutException) { } timer.Stop(); actualTime += (int)timer.ElapsedMilliseconds; timer.Reset(); } System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal; actualTime /= NUM_TRYS; //Verify that the time the method took to timeout is less then the maximum acceptable time retValue &= Eval(actualTime <= MAX_ACCEPTABLE_WARMUP_ZERO_TIMEOUT, String.Format("Err_112389ahbp!!!: With a timeout of 0 the read method timedout in {0} expected something less then {1}", actualTime, MAX_ACCEPTABLE_WARMUP_ZERO_TIMEOUT)); return(retValue); }
private void VerifyLongTimeout(ReadMethodDelegate readMethod, SerialPort com1, SerialPort com2) { var readThread = new ReadDelegateThread(com1.BaseStream, readMethod); var t = new Task(readThread.CallRead); t.Start(); Thread.Sleep(DEFAULT_WAIT_LONG_TIMEOUT); Assert.False(t.IsCompleted, string.Format("Err_17071ahpa!!! {0} terminated with a long timeout of {1}ms", readMethod.Method.Name, com1.BaseStream.ReadTimeout)); com2.Write(new byte[8], 0, 8); TCSupport.WaitForTaskCompletion(t); }
private void VerifyTimeout(ReadMethodDelegate readMethod, int readTimeout) { using (var com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { com1.Open(); com1.BaseStream.WriteTimeout = 1; com1.BaseStream.ReadTimeout = 1; com1.BaseStream.ReadTimeout = readTimeout; Assert.True(readTimeout == com1.BaseStream.ReadTimeout, string.Format("Err_236897ahpbm!!! Expected ReadTimeout to be {0} actaul {1}", readTimeout, com1.BaseStream.ReadTimeout)); VerifyTimeout(readMethod, com1.BaseStream); } }
private void Verify0Timeout(ReadMethodDelegate readMethod) { using (var com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { com1.Open(); com1.BaseStream.WriteTimeout = 1; com1.BaseStream.ReadTimeout = 1; com1.BaseStream.ReadTimeout = 0; Assert.True(0 == com1.BaseStream.ReadTimeout, string.Format("Err_72072ahps!!! Expected ReadTimeout to be {0} actual {1}", 0, com1.BaseStream.ReadTimeout)); Verify0Timeout(readMethod, com1.BaseStream); } }
private void VerifyDiscardNullAfterOpen(bool discardNull, ReadMethodDelegate readMethod, bool sendNewLine) { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { SerialPortProperties serPortProp = new SerialPortProperties(); serPortProp.SetAllPropertiesToOpenDefaults(); serPortProp.SetProperty("PortName", TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); com1.Open(); com1.DiscardNull = discardNull; serPortProp.SetProperty("DiscardNull", discardNull); serPortProp.VerifyPropertiesAndPrint(com1); VerifyDiscardNull(com1, readMethod, sendNewLine); serPortProp.VerifyPropertiesAndPrint(com1); } }
private void VerifyLongTimeout(ReadMethodDelegate readMethod, SerialPort com1, SerialPort com2) { var readThread = new ReadDelegateThread(com1.BaseStream, readMethod); var t = new Thread(readThread.CallRead); t.Start(); Thread.Sleep(DEFAULT_WAIT_LONG_TIMEOUT); Assert.True(t.IsAlive, string.Format("Err_17071ahpa!!! {0} terminated with a long timeout of {1}ms", readMethod.Method.Name, com1.BaseStream.ReadTimeout)); com2.Write(new byte[8], 0, 8); while (t.IsAlive) { Thread.Sleep(10); } }
private void VerifyDefaultTimeout(ReadMethodDelegate readMethod) { using (var com1 = TCSupport.InitFirstSerialPort()) using (var com2 = TCSupport.InitSecondSerialPort(com1)) { com1.Open(); if (!com2.IsOpen) { com2.Open(); } com1.BaseStream.WriteTimeout = 1; Assert.Equal(-1, com1.BaseStream.ReadTimeout); VerifyLongTimeout(readMethod, com1, com2); } }
public void VerifyInfiniteTimeout(ReadMethodDelegate readMethod, bool setInfiniteTimeout) { using (SerialPort com1 = TCSupport.InitFirstSerialPort()) using (SerialPort com2 = TCSupport.InitSecondSerialPort(com1)) { ReadDelegateThread readThread = new ReadDelegateThread(com1, readMethod); System.Threading.Thread t = new System.Threading.Thread(readThread.CallRead); SerialPortProperties serPortProp = new SerialPortProperties(); serPortProp.SetAllPropertiesToOpenDefaults(); serPortProp.SetProperty("PortName", TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); serPortProp.SetProperty("WriteTimeout", 10); com1.WriteTimeout = 10; com1.Open(); if (!com2.IsOpen) { com2.Open(); } if (setInfiniteTimeout) { com1.ReadTimeout = 500; com1.ReadTimeout = SerialPort.InfiniteTimeout; } t.Start(); System.Threading.Thread.Sleep(DEFAULT_WAIT_INFINITE_TIMEOUT); Assert.True(t.IsAlive); serPortProp.VerifyPropertiesAndPrint(com1); com2.WriteLine(string.Empty); while (t.IsAlive) { System.Threading.Thread.Sleep(10); } } }
public bool VerifyLongTimeout(ReadMethodDelegate readMethod, SerialPort com1, SerialPort com2) { ReadDelegateThread readThread = new ReadDelegateThread(com1.BaseStream, readMethod); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(readThread.CallRead)); bool retValue = true; t.Start(); System.Threading.Thread.Sleep(DEFAULT_WAIT_LONG_TIMEOUT); retValue &= Eval(t.IsAlive, String.Format("Err_17071ahpa!!! {0} terminated with a long timeout of {1}ms", readMethod.Method.Name, com1.BaseStream.ReadTimeout)); com2.Write(new byte[8], 0, 8); while (t.IsAlive) { System.Threading.Thread.Sleep(10); } return(retValue); }
private bool VerifyParityReplaceByteAfterOpen(int parityReplace, ReadMethodDelegate readMethod, bool newLine) { bool retValue = true; SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName); com1.Open(); com2.Open(); com1.ParityReplace = (byte)parityReplace; retValue &= VerifyParityReplaceByte(com1, com2, readMethod, newLine); com1.Close(); com2.Close(); if (!retValue) { Console.WriteLine("Err_0825qnza Verifying setting ParityReplaceByte AFTER calling Open failed ParityReplace={0}", parityReplace); } return(retValue); }
private bool Verify0Timeout(ReadMethodDelegate readMethod) { SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); bool retValue = true; com1.Open(); com1.BaseStream.WriteTimeout = 1; com1.BaseStream.ReadTimeout = 1; com1.BaseStream.ReadTimeout = 0; retValue &= Eval(0 == com1.BaseStream.ReadTimeout, String.Format("Err_72072ahps!!! Expected ReadTimeout to be {0} actaul {1}", 0, com1.BaseStream.ReadTimeout)); retValue &= Verify0Timeout(readMethod, com1.BaseStream); if (com1.IsOpen) { com1.Close(); } return(retValue); }
private bool VerifyDiscardNullAfterOpen(bool discardNull, ReadMethodDelegate readMethod, bool sendNewLine) { SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); SerialPortProperties serPortProp = new SerialPortProperties(); bool retValue = true; serPortProp.SetAllPropertiesToOpenDefaults(); serPortProp.SetProperty("PortName", TCSupport.LocalMachineSerialInfo.FirstAvailablePortName); com1.Open(); com1.DiscardNull = discardNull; serPortProp.SetProperty("DiscardNull", discardNull); retValue &= serPortProp.VerifyPropertiesAndPrint(com1); retValue &= VerifyDiscardNull(com1, readMethod, sendNewLine); retValue &= serPortProp.VerifyPropertiesAndPrint(com1); if (com1.IsOpen) { com1.Close(); } return(retValue); }
private void VerifyLongTimeout(ReadMethodDelegate readMethod, int readTimeout) { using (var com1 = TCSupport.InitFirstSerialPort()) using (var com2 = TCSupport.InitSecondSerialPort(com1)) { com1.Open(); if (!com2.IsOpen) { com2.Open(); } com1.BaseStream.WriteTimeout = 1; com1.BaseStream.ReadTimeout = 1; com1.BaseStream.ReadTimeout = readTimeout; Assert.True(readTimeout == com1.BaseStream.ReadTimeout, string.Format("Err_7071ahpsb!!! Expected ReadTimeout to be {0} actaul {1}", readTimeout, com1.BaseStream.ReadTimeout)); VerifyLongTimeout(readMethod, com1, com2); } }
private void VerifyRead(SerialPort com1, SerialPort com2, byte[] bytesToWrite, char[] expectedChars, ReadMethodDelegate readMethod, bool newLine) { com2.Write(bytesToWrite, 0, bytesToWrite.Length); if (newLine) { com2.Write(com1.NewLine); while (bytesToWrite.Length + com1.NewLine.Length > com1.BytesToRead) { } } else { TCSupport.WaitForReadBufferToLoad(com1, bytesToWrite.Length); } char[] actualChars = readMethod(com1); //Compare the chars that were written with the ones we expected to read for (int i = 0; i < expectedChars.Length; i++) { if (actualChars.Length <= i) { Fail("ERROR!!!: Expected more characters then were actually read"); } else if (expectedChars[i] != actualChars[i]) { Fail("ERROR!!!: Expected to read {0} actual read {1} at {2}", (int)expectedChars[i], (int)actualChars[i], i); } } if (actualChars.Length > expectedChars.Length) { Fail("ERROR!!!: Read in more characters then expected"); } }
private void VerifyParityReplaceByte(int parityReplace, ReadMethodDelegate readMethod, bool newLine) { VerifyParityReplaceByteBeforeOpen(parityReplace, readMethod, newLine); VerifyParityReplaceByteAfterOpen(parityReplace, readMethod, newLine); }
private void VerifyParityReplaceByte(ReadMethodDelegate readMethod, bool newLine) { Random rndGen = new Random(); VerifyParityReplaceByte(rndGen.Next(1, 128), readMethod, newLine); }
private void VerifyDiscardNull(SerialPort com1, ReadMethodDelegate readMethod, bool sendNewLine) { using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { char[] expectedChars; char[] rcvChars; int origReadTimeout; char[] xmitChars = new char[DEFAULT_NUM_CHARS_TO_WRITE]; byte[] xmitBytes; byte[] expectedBytes; Random rndGen = new Random(); int numNulls = 0; int expectedIndex; origReadTimeout = com1.ReadTimeout; //Generate some random chars to transfer for (int i = 0; i < xmitChars.Length; i++) { //xmitChars[i] = (char)rndGen.Next(1, UInt16.MaxValue); xmitChars[i] = (char)rndGen.Next(60, 80); } //Inject the null char randomly for (int i = 0; i < DEFUALT_NUM_NULL_CHAR; i++) { int nullIndex = rndGen.Next(0, xmitChars.Length); if ('\0' != xmitChars[nullIndex]) { numNulls++; } xmitChars[nullIndex] = '\0'; } xmitBytes = com1.Encoding.GetBytes(xmitChars); if (com1.DiscardNull) { expectedIndex = 0; expectedChars = new char[xmitChars.Length - numNulls]; for (int i = 0; i < xmitChars.Length; i++) { if ('\0' != xmitChars[i]) { expectedChars[expectedIndex] = xmitChars[i]; expectedIndex++; } } } else { expectedChars = new char[xmitChars.Length]; Array.Copy(xmitChars, expectedChars, expectedChars.Length); } expectedBytes = com1.Encoding.GetBytes(expectedChars); expectedChars = com1.Encoding.GetChars(expectedBytes); com2.Open(); com2.Write(xmitBytes, 0, xmitBytes.Length); TCSupport.WaitForReadBufferToLoad(com1, expectedBytes.Length); if (sendNewLine) { com2.WriteLine(""); } com1.ReadTimeout = 250; rcvChars = readMethod(com1); Assert.Equal(0, com1.BytesToRead); Assert.Equal(expectedChars, rcvChars); com1.ReadTimeout = origReadTimeout; } }
internal protected async Task <IDisposable> WatchNonVoidSignalAsync <T>(string iface, string member, Action <Exception> error, Action <T> action, ReadMethodDelegate <T> readValue, bool isPropertiesChanged) { var synchronizationContext = _connection.CaptureSynchronizationContext(); var wrappedDisposable = new WrappedDisposable(synchronizationContext); SignalHandler handler = (msg, ex) => { if (ex != null) { if (error == null) { return; } wrappedDisposable.Call(error, ex, disposes: true); return; } if (!SenderMatches(msg)) { return; } var reader = new MessageReader(msg, _factory); if (isPropertiesChanged) { var eventIface = reader.ReadString(); if (eventIface != iface) { return; } reader.SetSkipNextStructPadding(); } var value = readValue(reader); wrappedDisposable.Call(action, value); }; if (isPropertiesChanged) { wrappedDisposable.Disposable = await _connection.WatchSignalAsync(ObjectPath, "org.freedesktop.DBus.Properties", "PropertiesChanged", handler); } else { wrappedDisposable.Disposable = await _connection.WatchSignalAsync(ObjectPath, iface, member, handler); } return(wrappedDisposable); }
public ReadDelegateThread(Stream stream, ReadMethodDelegate readMethod) { _stream = stream; _readMethod = readMethod; }
internal protected async Task <T> CallNonVoidMethodAsync <T>(string iface, string member, Signature?inSignature, MessageWriter writer, ReadMethodDelegate <T> readValue) { var reader = await SendMethodReturnReaderAsync(iface, member, inSignature, writer); return(readValue(reader)); }