Asynchronous programming is simply allowing some portions of code to be executed on separate threads. It makes your applications perform better, be more responsive, and use the resources of the system they are running on to the fullest extent.
1
vote
1answer
42 views
Interface implementations: sync methods in terms of async methods
Say I have an interface and I want to expose both synchronous and asynchronous options for performing an action:
public interface MyInterface
{
Task<SomeResult> FetchSomeThingsAsync();
...
4
votes
2answers
68 views
Wait until all files are loaded asynchronously, then run code
I'm an experienced programmer but not too great at JavaScript so I'm looking to see if I'm doing this 'right'. I want to have several files loaded in (Ajax or really AJAJ) and, once loaded, run some ...
3
votes
0answers
22 views
Optimizing async joins for mongodb (mongoose) using async.js
I'm building a media viewer web app for a kiosk in node that uses data in mongo. To render the viewer, it gathers together all the Asset objects (representing video files), each of which belong to a ...
4
votes
1answer
88 views
Writing highly asynchronous code
I am writing a new web service that will be performing a lot of large data load operations. To do so I am moving the data to a temporary table then merging the data in to the live data via a stored ...
2
votes
1answer
76 views
Is this a good use of Async in F#?
I've hacked together some code to read the content from a sequence of files:
let fileContents =
[ "filename1"; "filename2"; "etc" ]
|> Seq.map(fun file -> async {
use fs = new ...
3
votes
0answers
36 views
Queue with “unlimited” buffer in Go
This is small piece of bigger puzzle, but usable by its own.
It an attempt to have a nonblocking queue with "unlimited" (besides memory size) buffer length.
Got unit-tests 100% statement coverage, it ...
2
votes
0answers
77 views
Aysnc c++ call back to UI Thread
My main Dll is a .Net one, that got an async running method and fires an event when it's done:
public class LicenceVerifier
{
private readonly ILicence _licence;
private readonly int ...
6
votes
1answer
177 views
Continuously receive messages async from Azure Service Bus Queues
I'd like to get input on my approach of continuously receiving messages from an Azure Service Bus queue using the async part of the library.
My main concern being whether its "safe" to use ...
2
votes
1answer
238 views
Android AsyncTask, HTTP Request and Parsing
I am working on Android applications for last 2 years and about 80% applications I have developed involve web-services consumption followed by some sort of XML or JSON parsing. Initially, when I had ...
10
votes
2answers
257 views
BackgroundWorker vs TPL ProgressBar Exercise
I wanted to fiddle around with the BackgroundWorker and Task classes, to see how I would implement a given task with these two techniques.
So I created a new WinForms project, and implemented a ...
3
votes
0answers
50 views
Semi-synchronous Programming in Python
I just took a stab at creating a library for something I'm dubbing semi-synchronous programming (async + dependencies). It's rather dense, but I'd really appreciate a quick code review to ensure I'm ...
1
vote
0answers
24 views
Paginated Backbone.Collection subclass
This is a subclass of Backbone.Collection with a method fetchNextPage that returns a Q promise.
To find out the next page's URL, it looks in meta.next from server response.
The server will return ...
1
vote
1answer
64 views
Best way to handle the error in async node
To catch errors, I have written if-else blocks in every function which looks bad. Please suggest a better way to handle errors in async node.
async.waterfall([
function(callback){
...
4
votes
2answers
68 views
Refactoring asynchronous JS pre-rendering code
A few months ago I wrote this module but, coming back to it, I find it a bit hard to read and reason about. I want to ask community's opinion on whether this needs to be refactored, and how I could ...
2
votes
1answer
94 views
Limiting Q promise concurrency in JavaScript
I wrote a helper to limit Q promise concurrency.
If I have a promise-returning function promiseSomething, writing
promiseSomething = PromiseScheduler.limitConcurrency(promiseSomething, 5);
ensures ...
3
votes
1answer
265 views
Node.js Async Callback Hell
Attempting to create a final array with data pulled from 3 functions. The first two functions have all the data but then the 3rd function needs to run looping through one of the fields from function 2 ...
2
votes
1answer
151 views
Generic Task Progress Dialog
I'm attempting to write a Progress Dialog that I can instantiate, show and then pass a task to complete to. I'm pretty new to Task Based Patterns, so please bear with me.
Ideally my goal is to be ...
4
votes
1answer
290 views
simple ThreadPool implementations
I would like to ask you for a code review of my c++11 Thread Pool implementation. Your constructive criticism is welcome! Could you give me some ideas how to extend it?
The main idea is to ...
6
votes
3answers
220 views
“Proper” Asynchronous implementation
I need some opinion if my code below is proper for an async process. This code only reformats text. Please let me know if this implementation is not proper or needs some improvement.
static void ...
3
votes
1answer
141 views
AsyncTask for handling server api calls
Got this design for getting rid of checking network availability and informing user of errors. Is it good at all? Please, help.
Overall point is to fire server call as short as possible:
new ...
1
vote
1answer
251 views
Node.js DynamoDB callback
I am writing an API which gets results from a DynamoDB table and puts the JSON back into the browser.
The code below works and returns the desired results. However, after reading about async and ...
2
votes
1answer
100 views
Am I using Q the right way or is there a better way to do what I'm doing?
I'm using Q to flatten out some callbacks in my unit tests and return a promise to mocha (which knows to wait until the promise is resolved before running the next test).
Originally I had this code:
...
2
votes
1answer
180 views
DAL Efficiency Help
I am attempting my first try at some c#. So far I love it, (not more than vb tho ;)) however, I am wondering if I can make these classes a bit more efficient.
Please note ###Test is my attempts at ...
1
vote
2answers
366 views
Static classes, singleton and thread-safety
I have a classes for work with a web service (Windows Phone 8 app). I will briefly describe what doing each. My main question is the thread-safety of the solutions. I think there will be problems ...
2
votes
2answers
216 views
Timer factory fn optimization
I use this Timer function quite a bit lately for all sorts of stuff,
and would appreciate if someone could review/analize/criticize/verify
and, of course, suggest things I can do to optimize it for ...
1
vote
0answers
537 views
Javascript Queue for async functions
Based on the answer to my previous question on Stack Overflow, I put together the following Queue class. I realize there are already libraries out there to do this. However, I wanted to actually ...
1
vote
1answer
83 views
Node.js/javascript: synchronizing async tasks
Yes, I know there are plenty of libraries to get this done (Q, step, async), but only for learning I'm wondering if the following code is ok and usable or have major drawbacks and it is only usable at ...
1
vote
0answers
328 views
Asynchronous Server Sockets - Thread-Safety/Performance (MMO Gaming)
I'm writing this game server for my small 2D MMO game.
So here are my questions:
What do you think about the Thread-Safety of the code?
Please explain how can it be made thread-safe / show example/ ...
1
vote
1answer
224 views
Is this factory method a good approach?
We are beginning to learn Node.js and we are not always sure if we do it the right way. We have a strong object oriented background so the adoption is not always easy. Right now we implemented a ...
1
vote
2answers
56 views
functional javascript - how could I generalize this code that correlates parallel async requests with their results?
/**
* takes a list of componentIDs to load, relative to componentRoot
* returns a promise to the map of (ComponentID -> componentCfg)
*/
function asyncLoadComponents (componentRoot, components) ...
1
vote
0answers
401 views
WCF using TAP without worrying about timeouts
I am really liking using the new TAP pattern in .net 4.5. And am updating some of my older projects to use it.
One of the old patterns I used to use was to use EAP with WCF so I could have functions ...
5
votes
2answers
6k views
TCP async socket server client communication
I develop my first async TCP socket server and client program in c# and would like to review the first parts of it. I like to get some information’s about smelly code that I missed and what I could ...
2
votes
2answers
591 views
Asynchronous version of AutoResetEvent
This is my second attempt to create asynchronous version of AutoResetEvent.
At first I tried to make it completely lock-less, but it turned out to be impossible.
This implementation contains a lock ...
6
votes
1answer
146 views
AutoResetEventAsync, am I missing something?
So I wrote an asynchronous version of AutoResetEvent:
public sealed class AutoResetEventAsync {
private readonly Task<bool> falseResult = Task.FromResult(false);
private readonly ...
1
vote
1answer
804 views
Simple Telnet Chat Server nodejs (correct way to write programs in node.js (asynchronous programming model))
I am new to node.js and asynchronous programming and this is my first small project to learn it. I have written a small Telnet Chat server and the program works but I want to know if this is the ...
2
votes
1answer
175 views
Am I using async C# correctly?
I have the following bit of code the calls out to two different command line components (each wrapped in their own Task)
public async Task<FileInfo> RasterizeAllPdfs(IEnumerable<Uri> ...
2
votes
1answer
2k views
Use and Understanding of async/await in .NET 4.5 +
All, please take the following example code
CancellationTokenSource cancelSource;
// Mark the event handler with async so you can use await in it.
private async void StartButton_Click(object ...
1
vote
1answer
774 views
TPL Thread Leak and Memory Leak
I'm trying to track down what I suppose to be memory/thread leak in one of my programs.
My program uses a function to upload a file to a Windows Azure Storage Blob. In order to make this function ...
0
votes
1answer
89 views
Perfomance and Other Improvements
I am trying to wrap my arms around all the digital files we have, so I thought I would organize all of our pictures and videos into folders named after dates. I'm learning F#, and this felt like a ...
2
votes
1answer
342 views
Putting called delegate into AsyncState parameter - Pros/cons?
I have the following interface:
public interface ILogger
{
void Log(string message, string title, StatusType type, DateTime timestamp);
IAsyncResult LogAsync(string message, string title, ...
2
votes
1answer
3k views
Correct approach to wait for multiple async methods to complete
I have an IWorkflow interface defined as follows:
public interface IWorkflow
{
Task ConfigureAsync();
Task StartAsync();
Task StopAsync();
}
And I have an Engine class:
public sealed ...
2
votes
3answers
236 views
(async) Task “Keeper” for keeping the “fresh” data - How do I improve this?
Background
I retrieve data from a 3rd party API, over HTTP. It's often slow, and sometimes just fails.
I needed a class that would keep getting data from that source, and keep it in memory.
So, ...
3
votes
1answer
191 views
Very simple async MixpanelAPI
I would love to hear feedback on my first open source project (a very simple async API for Mixpanel).
It implements a REST client for this REST HTTP API.
Review requested on the following aspects:
...
2
votes
3answers
329 views
Polling a email using async / await
I've created a create a console app that would:
Call a method to check an email account (I've done this step)
Convert the attachment to pdf (I've done this step)
Then once the conversion is complete ...
3
votes
1answer
268 views
Interview example [closed]
Recently I participated in an interview for a Russian company in Moskow and could not answer some of the simple questions. One of them I would like to ask here.
List all problems which you can see in ...
8
votes
2answers
4k views
Real World Async and Await Code Example
I have been looking everywhere to find good real world examples of the new Async and Await features in .net 4.5. I have come up with the following code to download a list of files and limit the number ...
1
vote
1answer
239 views
Calling a function when all asynchronous calls complete
Below is a simplified version of some code I am using to execute a function after all asynchronous calls complete. Is this a reasonable piece of code? It seems to work. Nothing would break if ...
5
votes
1answer
1k views
A blocking buffer manager to provide segments of a byte array
Since asynchronous operations (like Socket's Begin*-End* pairs and *Async methods) that use IOCP under the hood cause the byte array that you use as buffer to be pinned in the memory.
So if you ...
7
votes
1answer
549 views
Asynchronous leadership election
The following code should be mostly OK, but I'm trying to avoid any stylistic problems or find anything that I overlooked.
The code is an implementation of asynchronous leadership election on a one ...
0
votes
1answer
41 views
Processing a collection of objects, one at a time, with an asynchronous method.
I currently use setInterval and a wait flag to process this collection. Is there a cleaner way?
var wait = false;
var processInterval = setInterval(function(){
if(!wait){
var currentVideo ...