Questions tagged [asynchronous]

Asynchronous programming is a strategy for deferring operations with high latency or low priority, usually in an attempt to improve performance, responsiveness, and / or composability of software. Such strategies are usually employed using some combination of event-driven programming and callbacks, and optionally making use of concurrency through coroutines and / or threads.

Asynchronous programming is a strategy for deferring operations with high latency or low priority, usually in an attempt to improve performance, responsiveness, and / or composability of software. Such strategies are usually employed using some combination of event-driven programming and callbacks, and optionally making use of concurrency through coroutines and / or threads.

Asynchronous programming is used in many situations:

  • handling user input in UIs and games,
  • processing network traffic,
  • performing disk I/O,
  • batching work,
  • and more.

Asynchronous programming models can aid in software composition in many languages (notably languages where functions are first-class types) and APIs providing callback-based completion messaging. Proper use of this programming methodology can improve throughput and improve responsiveness by reducing total latency of job batches when executed in parallel. This approach can also result in an increase in system throughput at the cost of increased operational latency resulting from deferred processing.

50995 questions
13
votes
3 answers

redux-thunk and handling exceptions inside dispatch results

I have a basic thunk action creator and reducer adapted from the Redux documentation: http://redux.js.org/docs/advanced/AsyncActions.html // action creator function fetchPosts () { return dispatch => { dispatch({ type: 'FETCH_POSTS_REQUEST'…
Matt Stone
  • 3,705
  • 4
  • 23
  • 40
13
votes
2 answers

How to export an object returned by async/await method

As Async always returns promise, we have to resolve it to get the value. I need to export it's value (returned object) so that we can use it in another module. export const getClient = async () => { return await…
TechTurtle
  • 2,667
  • 4
  • 22
  • 31
13
votes
5 answers

How to block on asynchronous functions in JavaScript

I need to write a function in JavaScript, which returns a state from calling an asynchronous function. However, the caller only receives the value and no callback function is to be provided. I tried something like: function getState() { var ret…
Ryan Li
  • 9,020
  • 7
  • 33
  • 62
13
votes
2 answers

.Net DownloadFileTaskAsync robust WPF code

The WPF code below hangs forever when network connection is lost for 3 or more minutes. When connection is restored it neither throws nor continues downloading nor timeouts. If network connection is lost for a shorter period say half a minute, it…
Serg
  • 22,285
  • 5
  • 21
  • 48
13
votes
2 answers

What's the best way of ensuring valid object lifespan when using Boost.Asio?

Been playing a lot with Boost.Asio of late. I like the library a lot since it offers a fantastic way to squeeze performance out of today's multicore systems. A question I have asked myself a few times, and I thought worth throwing out there regards…
jkp
  • 78,960
  • 28
  • 103
  • 104
13
votes
3 answers

How to collect array of emitted values from Observable.from?

So in Rxjs, I have bunch of code, return Observable.from(input_array) .concatMap((item)=>{ //this part emits an Observable.of for each item in the input_array }) …
tomriddle_1234
  • 3,145
  • 6
  • 41
  • 71
13
votes
2 answers

Should I use async if I'm returning a Task and not awaiting anything

In an async method where the code is not awaiting anything, is there a reason why someone would mark it async, await the task, and then return? Besides the potential un-necessity of it, what are the negative ramifications of doing so? For this…
contactmatt
  • 18,116
  • 40
  • 128
  • 186
13
votes
2 answers

How do I safely call an async method from EF's non-async SaveChanges?

I'm using ASP.NET Core, and EF Core which has SaveChanges and SaveChangesAsync. Before saving to the database, in my DbContext, I perform some auditing/logging: public async Task LogAndAuditAsync() { // do async stuff } public override int…
grokky
  • 8,537
  • 20
  • 62
  • 96
13
votes
1 answer

Angular2 - asynchronous dependency injection

I use Angular2 v2.2.3 I've created common module with forRoot() function, like this: ... public static forRoot(): ModuleWithProviders { return { ngModule: CommonsModule, providers: [ SomeOtherDependency, …
Mariusz.v7
  • 2,322
  • 2
  • 16
  • 24
13
votes
2 answers

Where do operations on models belong in Application Design Patterns?

Say we want to make an application containing the following: Asynchronous and time consuming operations on selected objects For a certain object we want to access the status of an associated operation. The ability to show, cancel and pause these…
13
votes
1 answer

Checked exception with CompletableFuture

Using Java 8 great feature CompletableFuture, I'd like to transform my old async code using exceptions to this new feature. But the checked exception is something bothering me. Here is my code. CompletableFuture asyncTaskCompletableFuture = …
Yolanda
  • 161
  • 1
  • 2
  • 8
13
votes
2 answers

In which case does TaskCompletionSource.SetResult() run the continuation synchronously?

Initially I thought that all continuations are executed on the threadpool (given a default synchronization context). This however doesn't seem to be the case when I use a TaskCompletionSource. My code looks something like this: Task Foo() { …
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
13
votes
1 answer

Unit testing Angular 2 components that are using observables and the async pipe

Using observable data services using the async pipe to update data directly in the view which is proving difficult to test (works fine normally). I want to be able to update the view, fire click events and then test that the model has been updated…
13
votes
1 answer

Do all C++ compilers support the async/await keywords?

I want to use async/await syntax in C++ (UE4 framework), but due to cross-platform code I not sure that is possible... Or possible? If yes, how can I use it? And also there are await and __await (resumable, yield and __yield_value also) keywords…
13
votes
0 answers

XCTest: NSURLSession: Stall on main thread

When running an XCTest that executes a network operation, i get the following error: -waitForExpectationsWithTimeout: timed out but was unable to run the timeout handler because the main thread was unresponsive (0.5 seconds is allowed after the wait…
FranticRock
  • 3,233
  • 1
  • 31
  • 56
1 2 3
99
100