Hi!
I try to convert some VB.NET 2003 code into C# 2003 code. Code uses
Sax.Communications COM-port control, and VB code is working fine.
Here is part of VB Class code I'm trying to convert...
Imports Sax.Communications '// Importing component Namespace
Private WithEvents _ComPort As SerialConnection '// Declaration Com-port
as Class Variable
_ComPort = New SerialConnection '// Creating instance, setup Com settings
_ComPort.Open() '// and open port for use
Private Sub _ComPort_DataAvailable(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles _ComPort.DataAvailable '// Event Handling
if data will be available
....
'// This sub saves available data into "ComBufferString"-property,
'// and it Raises there Event like
'// RaiseEvent ComBufferChanged(Me, New EventArgs)
....
End Sub
....and as C# code something like...
using Sax.Communications;
private SerialConnection _ComPort; // <- How to convert this like VB.NET
"WithEvents" ???
_ComPort = new SerialConnection();
_ComPort.Open();
private void _ComPort_DataAvailable(System.Object sender,
System.EventArgs e)
{
....
// This sub saves available data into "ComBufferString"-property,
// and it Raises there Event like
//if (ComBufferChanged != null) ComBufferChanged(this, new EventArgs());
....
}
My problem is: private void _ComPort_DataAvailable is never fired when
Com port has received data from device attached into COM-port :(
Propably VB code line...
Private WithEvents _ComPort As SerialConnection
.... is not correctly converted into C# as ...
private SerialConnection _ComPort;
or am I missing something?
--
Thanks in advance!
Mika