Click here to Skip to main content
15,902,112 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Serial Ports In VB Express Pin
Steve Pullan22-Aug-05 14:03
Steve Pullan22-Aug-05 14:03 
GeneralPrint Preview Pin
Anup Singh J21-Aug-05 1:14
Anup Singh J21-Aug-05 1:14 
GeneralRe: Print Preview Pin
Duncan Edwards Jones21-Aug-05 1:23
professionalDuncan Edwards Jones21-Aug-05 1:23 
GeneralCreating Class at run time Pin
Zahid Hayat20-Aug-05 21:20
Zahid Hayat20-Aug-05 21:20 
GeneralRe: Creating Class at run time Pin
Kevin McFarlane21-Aug-05 23:16
Kevin McFarlane21-Aug-05 23:16 
GeneralPublic Event Vs. Public Shared Event Pin
Ghazi Sarhan20-Aug-05 20:36
Ghazi Sarhan20-Aug-05 20:36 
GeneralRe: Public Event Vs. Public Shared Event Pin
rwestgraham21-Aug-05 10:41
rwestgraham21-Aug-05 10:41 
GeneralRe: Public Event Vs. Public Shared Event Pin
Ghazi Sarhan22-Aug-05 1:18
Ghazi Sarhan22-Aug-05 1:18 
rwestgraham wrote:
But it is not a good idea to use Shared in most cases, because typically you want events and property vcalues to be associated with a specific instance. When you raise a shared event, the application has no way of knowing which, if any, instance the event was raised from. Similarly, when you set the value of a shared property, the value will be set in any and all instances of the class.

Thank you rwestgraham for your reply...
My problem is i'm not rasing the event from within the constructor, i noticed that the event raised one of two times i click the button that raise the event, i posted the code below maybe this will help to understand the problem, the code is not completed 'cause i stopped once i noticed this problem:


The event that does not raise is the DataArrival event

Private Class UserConnection
    Private __TcpClient As TcpClient
    Private __ConnectionID As Integer
    Private __ReadBufferSize As Integer
    Private __ReadBuffer As Byte()

    Public Event DataArrival(ByVal ConnectionID As Integer, ByVal rDataByte As Byte(), ByVal rDataStr As String)
    Public Event ConnectionLost()
    Public Event ConnectionClosedByClient()

    Public Sub New(ByVal ClientConnection As TcpClient, Optional ByVal ReadBufferSize As Integer = 255)
        __TcpClient = ClientConnection
        __ReadBufferSize = ReadBufferSize
        ReDim __ReadBuffer(__ReadBufferSize)
        Me.__TcpClient.GetStream.BeginRead(__ReadBuffer, 0, __ReadBufferSize, AddressOf StartRead, Nothing)
    End Sub
    Private Sub StartRead(ByVal AR As IAsyncResult)
        Dim BytesRead As Integer
        Dim strMessage As String

        Try
            SyncLock __TcpClient.GetStream
                BytesRead = __TcpClient.GetStream.EndRead(AR)
            End SyncLock

            strMessage = Encoding.ASCII.GetString(__ReadBuffer, 0, BytesRead)
            RaiseEvent DataArrival(__ConnectionID, __ReadBuffer, strMessage)

            SyncLock __TcpClient.GetStream
                ReDim __ReadBuffer(__ReadBufferSize)
                __TcpClient.GetStream.BeginRead(__ReadBuffer, 0, __ReadBufferSize, AddressOf StartRead, Nothing)
            End SyncLock
        Catch e As SocketException
            MessageBox.Show(e.ToString, e.NativeErrorCode.ToString)
        End Try
    End Sub
    Public Sub SendData(ByVal Data As String)
        SyncLock __TcpClient.GetStream
            Dim writer As New IO.StreamWriter(__TcpClient.GetStream)
            writer.Write(Data)
            writer.Flush()
        End SyncLock
    End Sub
    Public Sub SendData(ByVal Data As Byte())
        SyncLock __TcpClient.GetStream
            Dim writer As New IO.StreamWriter(__TcpClient.GetStream)
            writer.Write(Data)
            writer.Flush()
        End SyncLock
    End Sub
    Public Property ConnectionId() As Integer
        Get
            Return __ConnectionID
        End Get
        Set(ByVal Value As Integer)
            __ConnectionID = Value
        End Set
    End Property
End Class

GeneralRe: Public Event Vs. Public Shared Event Pin
rwestgraham22-Aug-05 9:02
rwestgraham22-Aug-05 9:02 
QuestionWebService timeout .... why? Pin
MaWeRic20-Aug-05 10:13
MaWeRic20-Aug-05 10:13 
GeneralGrabbing form's content Pin
Prakash Sachania20-Aug-05 8:02
sussPrakash Sachania20-Aug-05 8:02 
GeneralRe: Grabbing form's content Pin
thebread21-Aug-05 2:24
thebread21-Aug-05 2:24 
Generalsimple datagrid relation display Pin
Member 145166320-Aug-05 2:12
Member 145166320-Aug-05 2:12 
GeneralProblem programmatically downloading file from forms authenticated site Pin
Jim Taylor19-Aug-05 23:27
Jim Taylor19-Aug-05 23:27 
Generalcom+ serviced component Pin
mailmechandru19-Aug-05 21:46
mailmechandru19-Aug-05 21:46 
GeneralRe: com+ serviced component Pin
Rizwan Bashir20-Aug-05 2:14
Rizwan Bashir20-Aug-05 2:14 
GeneralRe: com+ serviced component Pin
mailmechandru22-Aug-05 20:09
mailmechandru22-Aug-05 20:09 
GeneralRe: com+ serviced component Pin
Rizwan Bashir22-Aug-05 21:59
Rizwan Bashir22-Aug-05 21:59 
GeneralRe: com+ serviced component Pin
mailmechandru23-Aug-05 2:44
mailmechandru23-Aug-05 2:44 
GeneralRe: com+ serviced component Pin
Rizwan Bashir23-Aug-05 22:21
Rizwan Bashir23-Aug-05 22:21 
GeneralRe: com+ serviced component Pin
mailmechandru24-Aug-05 21:00
mailmechandru24-Aug-05 21:00 
GeneralRe: com+ serviced component Pin
Rizwan Bashir24-Aug-05 22:06
Rizwan Bashir24-Aug-05 22:06 
GeneralRe: com+ serviced component Pin
mailmechandru25-Aug-05 0:33
mailmechandru25-Aug-05 0:33 
GeneralRe: com+ serviced component Pin
Rizwan Bashir26-Aug-05 0:12
Rizwan Bashir26-Aug-05 0:12 
GeneralRe: com+ serviced component Pin
mailmechandru24-Aug-05 21:05
mailmechandru24-Aug-05 21:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.