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 8416227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:41:16+00:00 2026-06-10T01:41:16+00:00

I am developping a client library for a network application protocol. Client code calls

  • 0

I am developping a client library for a network application protocol.

Client code calls the library to init it and to connect to server.
The client can of course send requests to the server, but the server can also send requests (Commands, called Cmd below) to the client.

The transport protocol is TCP/IP, so basically the client library connect to the server and make a call to an async method to retrieve the next request or response from the server in order to avoid I/O blocking while waiting for response/requests from the server.

That being said, I see two possible solutions (only using C# constructs and no specific third party framework) in the library to allow the client to receive requests from the server :

Either offer an event in the library such as

public EventHandler<ReceivedCmdEventArgs> event ReceivedCmd;

that the client would subscribe to, in order to get notidied of requests incoming from the server.
Of course for this mechanism I will have to make an async loop in the client library to receive requests from the server and raise the event on Cmd reception.

Or the other solution would be to make such a method in the client library

public async Task<Cmd> GetNextCmdAsync()

that the client code would call in an async loop to receive the cmds.

Are these solutions kind of the same ? Is it better to fully use async/await constrcuts of C#5 and not rely on events anymore ? What are the differences ? Any recommendation, remark ?

Thanks !

  • 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-06-10T01:41:18+00:00Added an answer on June 10, 2026 at 1:41 am

    I think that the event-driven approach is better in your case.

    In fact, you’re talking about an observable/observer pattern. An unknown number of listeners/observers are waiting to do something if some command is received.

    Async/await pattern wouldn’t work as well as event-driven approach, because it’d be something like I expect one result in opposite to I’ll do what you want whenever you report me that you received a command.

    Conceptually talking, I prefer the event-driven approach because it fits better with the goal of your architecture.

    Async/await pattern in C# 5 isn’t designed for your case, but it’s for when some code executes an async task and next code lines should be executed after the task has received a result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a library which you can use in client or server code. More
I'm currently developing a client/server application in Java and i can't make up my
I'm developing a Facebook iframe/Facebook Connect application with PHP client library. In my index
We're developing a client and server application for the library of the university. Beside
I'm developing client-server application by using .Net, C#, WCF, WPF. And now I need
I am developing an client server communication application in C. I want to encrypt
I'm developing a client-server application and have been tasked with adding support for running
I am developing a client-server application using .Net Remoting. From my server I want
I am developing a Client-Server based application in which client application will access server
I'm developping a communication library based on NIO's non-blocking SocketChannels so I can use

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.