방금 msdn을 탐색 한 결과이 page을 발견했습니다. 전에 함수 SerialPort.Flush()
또는 SerialPort.Finalize()
을 보지 못했습니다. 그래서 그 기능을 사용하려고했지만 오류가 발생했습니다. SerialPort.Flush() 및 SerialPort.Finalize() 함수에 액세스하는 방법
System.IO.Ports
네임 스페이스를 추가,하지만 난
Finalize()
기능에 대한 다음과 같은 오류 얻을 :
Cannot access protected member 'object.~Object()' via a qualifier of type 'System.IO.Ports.SerialPort'; the qualifier must be of type 'STP_Design.SerialCom' (or derived from it)
을하고 내가 Flush()
기능에 대한 다음과 같은 오류 얻을 :
'System.IO.Ports.SerialPort' does not contain a definition for 'Flush' and no extension method 'Flush' accepting a first argument of type 'System.IO.Ports.SerialPort' could be found (are you missing a using directive or an assembly reference?)
을 나는 잘못된 접근 방식으로 파이널 라이즈 함수에 접근하고 있다고 생각한다. (아마도 나는 그것을 접근해서는 안된다.) 그러나 나는 정말로 w이다. 무엇이 Flush()
함수에 대한 것인가?
나는 이런 식으로 뭔가를 사용 :
여기private void test()
{
SerialPort s1 = new SerialPort();
s1.PortName = "COM1";
s1.Open();
thread.Sleep(200);
s1.WriteLine("test");
s1.Flush();
s1.Close();
thread.Sleep(200);
s1.Finalize();
}
어떤 통찰력이?을
편집 :
finalizer를 직접 호출 할 수는 없습니다 ... – leppie
또한 'Flush' 메소드도 없습니다. 아마도'SerialPort.BaseStream.Flush' 시도해 볼 수 있습니다. – leppie
.NET Microframework의 설명서를보고 계십니다. – leppie