Home Forums Support Await Option

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3856
    Anonymous
    Inactive

    Hello,

    it’s possible to use the await operator in the SendReceive object?

    string loginResponse = await NetworkComms.SendReceiveObject<Objects.loginObj, string>
    ("loginRequest", serverIP, serverPort, "loginResponse", 10000, myCustomObject);

    Thanks

    • This topic was modified 7 years, 4 months ago by .
    • This topic was modified 7 years, 4 months ago by .
    #3859
    Anonymous
    Inactive

    Thanks for your question.

    NetworkComms.Net was designed to be .Net2 backwards compatible so offers both synchronous and asynchronous options. The example you have provided is the synchronous interface so an await would be somewhat defeating here.

    We have not yet come across any significant advantage in also supporting the more recent ‘await’ syntax.

    #3860
    Anonymous
    Inactive

    Hello, for using NetworkComms.SendReceive in async/await aware code you are encouraged to do the following:

    string result = await Task.Run(() => NetworkComms.SendReceive(...));

    This will give you “offloading” mainly for the UI by moving the blocking call into a separate task, however you still won’t benefit from “scalability” since NetworkComms was internally designed for .NET 2.0 as explained.

    For other constructions have in mind that NetworkComms uses the EAP (Event-based Asynchronous Pattern). You can refer to the MSDN for how to wrap this pattern into the TAP (Task-based Asynchronous Pattern).

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.