Asynchronous API call to update model in Rails

I am making a simple API call to Coinbase's API to get the current buy/sell price of bitcoin. I have a before_save action on my Price model class PriceBtc < ApplicationRecord before_save :save_prices def save_prices = PriceBtc.get_...
more »

2017-12-03 21:12 (1) Answers

Async/await performance

I'm working on performance optimization of the program which widely uses async/await feature. Generally speaking it downloads thousands of json documents through HTTP in parallel, parses them and builds some response using this data. We experience so...
more »

2017-11-26 12:11 (2) Answers

How does Task.Delay work exactly?

They say Task.Delay() is an async Thread.Sleep(). To test this I wrote below code. I expect to print immediately "One" then 3 seconds later result variable (15) will be printed. 2 seconds after this, "Two" will be printed. But it doesnt seem so. "One...
more »

2017-11-24 12:11 (3) Answers

Delayed progress reporting from async method

I have a WinForms application containing Button and a RichTextBox controls. After user clicks on Button, an IO demanding operation is executed. To prevent blocking of the UI thread I have implemented the async/await pattern. I would also like to repo...
more »

2017-11-24 12:11 (1) Answers

C# SQL connection OpenAsync is not asynchronous

I'm trying to open a connection to an SQL server asynchronously, so as not to tie up the UI thread. But I've found that the call to connection.OpenAsync() does not return until the connection has been opened, exactly as with connection.Open(). This ...
more »

2017-11-23 14:11 (2) Answers

Task.Delay in .net fires 125ms early

So I'm having a really strange behavior with a c# task delay that is kind of making me insane. Context: I'm using C# .net to communicate with one of our devices via R4852. The device needs roughly 200ms to finish each command so I introduced a 250m...
more »

2017-11-14 12:11 (1) Answers

async JS inside PHP & Wordpress

I have a Wordpress page Template, with custom queries to get all the child pages of a specific page with pagination. Here it is: <div id="content" class="content-area page-wrapper dc-coinsList" role="main"> <div class="section-container ...
more »

2017-10-31 19:10 (0) Answers

Async Task method WaitingForActivation

I have found a very confusing behavior of async methods. Consider the following Console app: private static int _i = 0; private static Task<int> _calculateTask = Task.FromResult(0); private static int _lastResult = 0; static void Main(string[...
more »

2017-10-27 04:10 (1) Answers

Can't use integer as an array index

I am trying to pass an integer to a Async task and access a list by that index withing. However I get this error "in List cannot be applied". Here is the relevant code. The Async task doesn't accept primitive int as an argument. src = new ArrayLi...
more »

2017-10-20 16:10 (3) Answers

Asp.Net mvc, How to make async and await method

I use this two actions to send email to admins about inventory status when it's time to make an order... But When I call SendEmailToAdminUser .. it takes time and side by side I cant work with other functions... waiting litle long.. I want to change ...
more »

2017-10-01 14:10 (1) Answers

await Task.WhenAll vs .. => await)

just a quick question. We're having some misunderstanding here. we have: var tasks = files.Select(async fileName => await IngestFileAsync(container, fileName)); var results = await Task.WhenAll(tasks); I say that the first line still goes conc...
more »

2017-09-28 09:09 (1) Answers