Differences in ansychronous VB.NET and C#???

Posted by Jim Beam on Stack Overflow See other posts from Stack Overflow or by Jim Beam
Published on 2010-04-16T18:03:38Z Indexed on 2010/04/16 20:23 UTC
Read the original article Hit count: 336

Filed under:
|
|

So I've been posting this week for help with an API that has asynchronous calls. You can view the CODE here: http://stackoverflow.com/questions/2638920/c-asynchronous-event-procedure-does-not-fire

With a little more digging, I found out that the API is written in VB.NET and I created a VB.NET example and guess what . . . the asynchronous calls work like a charm.

So, now I need to find out why the calls are not firing in the C# code I have. The API being written in VB really shouldn't matter, but again, the VB.NET code works and my C# does not. Is there a problem with the event handler and hows its being declared that causes it to not fire?

UPDATE VB Code added

Imports ClientSocketServices
Imports DHS_Commands
Imports DHS
Imports Utility
Imports SocketServices

Class Window1

    Public WithEvents AppServer As New ClientAppServer
    Public Token As LoginToken

    Private Sub login()

        Dim handler As New LoginHandler
        Token = handler.RequestLogin("admin", "admin", localPort:=12000, serverAddress:="127.0.0.1", serverLoginPort:=11000, clienttype:=LoginToken.eClientType.Client_Admin, timeoutInSeconds:=20)

        If Token.Authenticated Then
            AppServer = New ClientAppServer(Token, True)
            AppServer.RetrieveCollection(GetType(Gateways))
        End If

    End Sub

    Private Sub ReceiveMessage(ByVal rr As RemoteRequest) Handles AppServer.ReceiveRequest

        If TypeOf (rr.TransferObject) Is Gateways Then
            MsgBox("dd")
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        login()
    End Sub
End Class

© Stack Overflow or respective owner

Related posts about c#

Related posts about asynchronous