All Questions
Tagged with asynchronous-programming c#
32
questions
0
votes
2
answers
212
views
Why/When do we need to call an async method from a sync method?
It is my first question here so I hope I'm not doing a mistake. I see a plethora of questions in SO that people ask "how can I call an async method from a sync method?". Given my little ...
0
votes
1
answer
153
views
Is this the right way to call async and await
Hi I am new to async/await in C# . I have created a controller which is accessing result from HttpClient injected through HttpFactory. Here is my working example
class MyController
{
private ...
1
vote
1
answer
5k
views
How to approach a large number of multiple, parallel HttpClient requests?
I have a website which offers pages in the format of https://www.example.com/X where X is a sequential, unique number increasing by one every time a page is created by the users and never reused even ...
1
vote
0
answers
33
views
Using TPL to manage hundreds of contexts
Overview of application:
A chat bot that connects via IRC, using TPL. As messages come from the socket (from .ReadAsync()), they are ultimately parsed and passed to a handler within the bot itself (...
5
votes
3
answers
3k
views
Why is it necessary for every new api to be async?
I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. ...
0
votes
1
answer
142
views
I'm writing an application that needs to log error/ exception messages but should still continue execution if it not a fatal error
I'm writing an application that needs to log error/ exception messages but should still continue execution if the error is not a fatal error. I was thinking of making a method that returns a Task but ...
12
votes
1
answer
5k
views
Is the C# async/Task construct equivalent to Java's Executor/Future?
I'm a long time Java developer, but with so little traffic on SE, I don't limit my viewing to any single tags. I've noticed that C# questions with async/await come up a lot, and as far as I've read it'...
1
vote
1
answer
323
views
Refactor asynchronous code in C#
I got the following code snippet:
public Task DistributeAsync(BankAccount account, decimal amount)
{
lock (account)
{
return repository.AddLoanAsync(account, amount).ContinueWith(task ...
4
votes
2
answers
3k
views
Is it okay for async function to update a common object
I have a couple of functions, each function verifies a set of rules and updates a common object. The common object is just a container that holds a list of rules that passed or failed. I would like to ...
35
votes
2
answers
9k
views
Who did async/await first?
Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 ...
1
vote
1
answer
156
views
sequential command processing with an async io cloud upsert
We are new to c# and still trying to grok the async idioms.
We have a windows service that requires us to iterate a list of results queried from a PC database to feed the parse cloud server (which ...
4
votes
1
answer
987
views
Is it generally bad to await async operations in background processing (not needing the result)
So I've been working with background processing and event-driven systems, namely Azure WebJobs and ServiceBus. And while there is extensive use of async/await programming, I'm always wondering if it ...
3
votes
1
answer
164
views
Design for avoiding concurrent calls to an interface implementation
The application I'm developing requires that some data is obtained through different channels. As this is a network process, I have decided to use async programming.
I have designed the following ...
4
votes
1
answer
25k
views
Correct usage of async/await and Task.Run()
I am developing an application that will read excel files from disk and then process tests based on the data in the files. In order to keep the user interface from locking up when loading files and ...
5
votes
2
answers
253
views
Design of asynchronous component
I'm trying to design an asynchronous component. Requirements on this component are :
Component might receive events at any point in time
Component might start a long-running operation and wait for ...
2
votes
1
answer
870
views
Task Parallel Library Console Application Design - How do I lock a thread to a specific context?
I'm currently developing an application which relies on multiple sockets listening for chat messages. When the messages come in, they're passed off to a bot that's associated with their channels. ...
21
votes
3
answers
44k
views
Calling multiple async services in parallel
I have few async REST services which are not dependent on each other. That is while "awaiting" a response from Service1, I can call Service2, Service3 and so on.
For example, refer below code:
var ...
6
votes
1
answer
6k
views
Does omitting await keyword once in the call stack break the asynchronous behavior of the whole stack?
Call stack may contain several methods returning Task. If all of them are decorated with async, the flow of execution is quite simple. However, what if one of them is not awaited - are other method ...
1
vote
3
answers
1k
views
Use case for async/await?
Background
Most of the applications that I write are hour long sequential tests for electronic equipment. The equipment under test has a specification that is a state-machine that looks like...
Get ...
3
votes
3
answers
14k
views
Writing new code in async but calling sync
I am writing some new code and would like to write it using async and await, but the calling code does not currently support async. Is it right to write the new code in async and call it sync until ...
1
vote
1
answer
1k
views
HTTP Async/Await Task: avoid flooding server with requests?
I have a scenario where I have a Windows Store Application, there is a page with a search functionality, the user types names in a textbox and the app searches for names similar to the typed text.
...
6
votes
1
answer
2k
views
How is one supposed to deal with the intermediate buffer of DataReader class?
Summary
I am developing a WAV file format reader under WinRT, and for this I need to read random amounts of structs consisting of fundamental types such as int, uint, float and so on.
Back in ...
4
votes
2
answers
714
views
Async library guidance
I'm creating a library that contains a class that exposes several Async methods:
public class MyClass {
public async Task<Foo> DoFooAsync() { /*...*/ }
public async Task<Bar> ...
1
vote
1
answer
502
views
Mixing reactive programming with non-reactive return requirements
Variable context from an initial non-reactive caller
The whole application cannot be reactive i.e. this method needs to return a result here
public string GetTextOfInterest()
{
var ...
1
vote
1
answer
2k
views
C#/.NET multithreaded application design
The application to be designed serves as a bridge between two different systems.
One natively speaks TCP (RS232 actually, but there's a COM->ETH server in the line of communication) - the other one is ...
0
votes
1
answer
329
views
Async properties in interfaces to cater for the possibility of expensive first-time evaluation: Is this a good idea?
First of all, sorry if this post is too long. I'll start with the…
Short version:
Is it generally advisable or a good idea to design an interface property as asynchronous simply because we cannot be ...
12
votes
2
answers
20k
views
Efficient mixing of sync and async methods within a single method?
Okay, it sounds odd, but the code is very simple and explains the situation well.
public virtual async Task RemoveFromRoleAsync(AzureTableUser user, string role)
{
AssertNotDisposed();
var ...
7
votes
1
answer
2k
views
How can we calculate Big-O complexity in Functional & Reactive Programming
I started learning functional programming, I am trying to compare between different algorithms that are written in an imperative, functional , parallel programming and using Collections and Lambda ...
13
votes
1
answer
2k
views
Blurring the lines between async and regular functions in C# 5.0
Lately I can't seem to get enough of the amazing async-await pattern of C# 5.0. Where have you been all my life?
I'm absolutely thrilled with the simple syntax, but I'm having one small difficulty. ...
1
vote
1
answer
2k
views
Provide multiple SendCompleted callbacks to SmtpClient
I have an Email class that has a Send method that optionally takes an SmtpClient and sends an email asynchronously using SendAsync. If no SmtpClient is supplied to this method, it instantiates a ...
45
votes
5
answers
30k
views
async+await == sync?
Stumbled upon this post that talks about making async web requests.
Now simplicity aside, if in real world, all you do is make an async request and wait for it in the very next line, isn't that the ...
2
votes
3
answers
595
views
Transitioning to asynchronous programming model
Our team is mantaining and developing a .NET web service written in C#. We have stress tested the web service's farm and we have evidence that the actual architecture doesn't scale well, as the number ...