Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 735261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:28:07+00:00 2026-05-14T07:28:07+00:00

So I’ve been posting this week for help with an API that has asynchronous

  • 0

So I’ve been posting this week for help with an API that has asynchronous calls. You can view the CODE here: 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:28:08+00:00Added an answer on May 14, 2026 at 7:28 am

    You’re VB code is quite different from your c# code.
    Try converting your vb code to c#, but keep in mind that you don’t get WithEvents, so any time you
       AppServer = New ClientAppServer(Token, True);
    you will need to
       AppServer.ReceiveRequest += ReceiveMessage;

    EDIT: I converted your code using http://www.developerfusion.com/tools/convert/vb-to-csharp/ I also editted it by hand to make the events work. Keep in mind that I haven’t tested this; I apologize for any typos/etc.

    I’m also wondering, is your button click actually happening? Where is the event handler added check that it actually is in your IntializeComponent?

    
    using DHS;
    using Utility;
    using SocketServices;
    
    class Window1
    {
        
        public ClientAppServer AppServer = new ClientAppServer();
        public LoginToken Token;
        
    
        public Window1()
        {
          InitializeComponent();
        }
    
        private void login()
        {
            
            LoginHandler handler = 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) {
                AppServer = new ClientAppServer(Token, true);
                AppServer.ReceiveRequest += ReceiveMessage;
                AppServer.RetrieveCollection(typeof(Gateways));
                
            }
        }
        
        private void ReceiveMessage(RemoteRequest rr)
        {
            
            if ((rr.TransferObject) is Gateways) {
                MessageBox.Show("dd");
                
            }
        }
        
        private void Button1_Click(System.Object sender, System.Windows.RoutedEventArgs e)
        {
            login();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 366k
  • Answers 366k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The easiest way is to abstract the concept of the… May 14, 2026 at 4:36 pm
  • Editorial Team
    Editorial Team added an answer the class itself emulates a weak reference, and can be… May 14, 2026 at 4:36 pm
  • Editorial Team
    Editorial Team added an answer My issue was partly caused by also installing Visual Studio… May 14, 2026 at 4:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.