Click here to Skip to main content
14,739,326 members
Await

Await

Great Reads

by ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
by ipavlu
Optionally awaitable simple to use Concurrent Priority Queue.
by ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
by Marla Sukesh
In this article, you should have basic knowledge of web development and some features introduced in prior versions of .NET Framework, especially ASP.NET features.

Latest Articles

by ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.
by ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
by ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
by ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.

All Articles

Sort by Score

Await 

Please Sign up or sign in to vote.
24 Mar 2019
ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
Please Sign up or sign in to vote.
15 Mar 2016
RickZeeland
Here is a good article by Stephen Cleary: Async/Await - Best Practices in Asynchronous Programming[^]But I'm afraid he says what you don't want to hear:Quote:As you convert synchronous code to asynchronous code, you’ll find that it works best if asynchronous code calls and is called by...
Please Sign up or sign in to vote.
29 Dec 2017
ipavlu
Optionally awaitable simple to use Concurrent Priority Queue.
Please Sign up or sign in to vote.
12 Dec 2013
Sergey Alexandrovich Kryukov
Why?! Create a separate thread to work with each separate telnet server and work synchronously. Synchronize those threads using thread synchronization in those rare cases when it is needed.I think asynchronous APIs get popularity when threads were not a commonplace, or just because many...
Please Sign up or sign in to vote.
19 Jan 2016
Richard Deeming
How about something like this:public void GetDocumentWithCallback(Action callback, long ID){ Task task = GetDocumentAsync(ID); task.ContinueWith(t => callback(t.Result));}NB: Unlike the async version, callback will not be executed in the same context as...
Please Sign up or sign in to vote.
24 Mar 2019
ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
Please Sign up or sign in to vote.
15 Jul 2014
Matthew Dennis
// assuming you have created a CancellationToken so you can cancel the Telnet Monitors.List telnetTasks = new List();for (var i = 0; i
Please Sign up or sign in to vote.
21 Jan 2016
Richard Deeming
Assuming you want the return values to be 1 and 2, use the Interlocked.Increment Method[^] to increment the field, and store the result in a local variable to return at the end of the method:public class MyClass{ private int count = 0; public async Task GetCount() ...
Please Sign up or sign in to vote.
27 Nov 2016
Dave Kreskowiak
Your code is essentially single threaded. You've got 2 threads, but one is completely blocked waiting on the other. In any case, putting the LoadData code on a background thread, since it's the only thing you're doing, is no different than if you completely skipped all the Task/async/await...
Please Sign up or sign in to vote.
6 May 2019
OriginalGriff
Talk to the authors: if you go to your link page, you will find a line: Support questions: Stack Overflow[^] Follow the link, and ask them.
Please Sign up or sign in to vote.
21 Oct 2013
Marla Sukesh
In this article, you should have basic knowledge of web development and some features introduced in prior versions of .NET Framework, especially ASP.NET features.
Please Sign up or sign in to vote.
1 Mar 2019
ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.
Please Sign up or sign in to vote.
28 Oct 2014
dorodnic
Using the await keyword with Expression-Trees
Please Sign up or sign in to vote.
21 Jan 2021U
ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.
Please Sign up or sign in to vote.
9 Aug 2014
Talal Tayyab
The article provides a code first approach to understanding await/async and answers some of the basic questions.
Please Sign up or sign in to vote.
18 Feb 2014
Marc Clifton
Turns out I was calling the async read before the UI was up and running, so there was no continuation context!
Please Sign up or sign in to vote.
15 Mar 2016
Patrick Skelton
1 alternative  
Hi,I know the internet is littered with fragments of information on this subject, but none of them seems to provide a clear explanation of how you incorporate async functions into synchronous code.I seem to be caught between a rock and a hard place. I have to call an API that provides...
Please Sign up or sign in to vote.
22 Nov 2013
bowlturner
And why can't you just use System.Threading.Thread.Sleep(10000); in the while (!cancellationToken.IsCancellationRequested) Block?As far as how to wait for the GetRssItems you can use the ContinueWith to call a 'finish' or 'next' I have thisprivate void StartTask(long...
Please Sign up or sign in to vote.
10 Apr 2017
Swapnil Dhage
This is a helper/utility class that will add a layer of abstraction as well as separation for dispatcher related operations in WPF.
Please Sign up or sign in to vote.
14 Jul 2014
Sharath C V
A simple async / await example
Please Sign up or sign in to vote.
20 Sep 2015
Mithun Pattankar
Why build responsive UI? Answer seems obvious that end-user should experience that application doesn’t hang often (for developers POV, a time taking background operation makes it look like hanging). So lets learn building responsive UI using Async Await keywords Visual Studio 2012 introduced a
Please Sign up or sign in to vote.
22 Nov 2013
NeonMika
2 alternatives  
Hi codeproject-community!I'm just diggin' into the TAP and I'm hoping you can help me with a problem.Let me first explain what I want to achieve:I want to read from a RSS-feed every 10 seconds and want to write it's items to output it somehow on my form.My idea:I wrote an...
Please Sign up or sign in to vote.
22 Nov 2013
NeonMika
Okay, after reading some blogs i found some solution that work's pretty good for me: private Action getRss = null; private TaskScheduler ui = TaskScheduler.FromCurrentSynchronizationContext(); public ObservableCollection GuiListRssItems = new...
Please Sign up or sign in to vote.
11 Dec 2013
Member 10440446
2 alternatives  
Hi guys, any idea on how am I suppose to create an application on C# 5.0 using async await Telnet client.My scenario is that I have to telnet multiple servers at the same time. Also, i need it to check the servers continuously just like a ping /t function.Thanks much.. :)
Please Sign up or sign in to vote.
20 Dec 2013
Yvan Rodrigues
1 alternative  
The UI has a "loading" spinner. During the data loading below, the UI is responsive. During the LINQ, it freezes. The computer has 8 cores. public async static Task Load() { if (_loader == null) { _loader = Task.Run(() => ...
Please Sign up or sign in to vote.
20 Dec 2013
bowlturner
if you have visual studio 2012 or greater (.Net Framework 4.5 I think) you can use the Async keywords http://msdn.microsoft.com/en-us/library/hh156513.aspx[^]if not your mostly likely solution will be to put the linq on it's own thread.
Please Sign up or sign in to vote.
17 Feb 2014
Marc Clifton
1 alternative  
I thought one of the points about async/await is that when the task completes, the continuation is run on the same context when the await was called, which would, in my case, be the UI thread.So for example:System.Diagnostics.Debug.WriteLine("2: Thread ID: " +...
Please Sign up or sign in to vote.
30 Apr 2014
123456789igor
2 alternatives  
Hello, i try to write a simple asynchronous client/server apps. I know how do it using callback, but i want to invistigate how write client+server using await/async and c# 5.0. Please, help me. It should be simple. Only connect and transfer some bytes.I know that this can be done using...
Please Sign up or sign in to vote.
1 May 2014
123456789igor
now server can send to client array of byte. But client recieved only 1 iteration. How i can do, that if client connected then it always recieve information from server?Server:public ServerSocket(IPAddress ipAddress, int port) { _server = new...
Please Sign up or sign in to vote.
30 Jun 2014
Kyle Gottfried
I've been trying to turn the code sample at http://code.msdn.microsoft.com/office/CSVSTOViewWordInWPF-db347436[^] into an asynchronous program. I've been running into issues where running the program by calling AssignDocument(w,x) using await causes it to run synchronously instead of...
Please Sign up or sign in to vote.
14 Oct 2014
mahesh kumar BM
here is the below code that is used to get the list of templates from sendgrid using async and await feature. but due to some limitations i cant use these feature in my application which is in .net 3.5/4 and i use vs 2010. i just need the equivalent code which will run at background without...
Please Sign up or sign in to vote.
28 Nov 2014
girishkalamati
if its possible you can go on with spinning up multiple thread , to process the blob items as async process !u can use the following code , it will for sure improve the performance :async public static Task ListBlobsSegmentedInFlatListing(){ // Retrieve storage account from...
Please Sign up or sign in to vote.
8 Dec 2014
Santiago Fabian
2 alternatives  
Protected void Page_Load(object sender, EventArgs e){ XDocument response = ThirdPartyAPI.HttpRequest(someParams); if(response != null) { var node = response.Root.Elements("documents").Elements("document"); string url =...
Please Sign up or sign in to vote.
8 Dec 2014
Assil
Looks to me that ThirdPartyAPI.HttpRequest is asynchronous method, in which case there should be some method or property in ThirdPartyAPI that indicates whether the HttpRequest is still busy or done..and that very API could be used in lieu of if(response != null)Can you look into that?
Please Sign up or sign in to vote.
19 Jan 2016
Henrik R L
1 alternative  
HiI need to have my own C# function in both an awaitable async version and in a version that takes a callback function as a parameter and can be called from multiple threads at the same time. The callback version must be based on the async version.My awaitable function is:public...
Please Sign up or sign in to vote.
21 Jan 2016
Henrik R L
2 alternatives  
HiLet's say you have a function like:public class MyClass{ //Asume that this for some reason needs to be a member variable private int count=0; public async Task GetCount() { ++count; //Could be some real work to do in a...
Please Sign up or sign in to vote.
21 Jan 2016
Afzaal Ahmad Zeeshan
Because as per C#, it is illegal to do so. Quote[^]:An await expression cannot be used in a synchronous function, in a query expression, in the catch or finally block of an exception handling statement, in the block of a lock statement, or in an unsafe context.The thing is, if you call...
Please Sign up or sign in to vote.
26 Apr 2016
Member 10312908
2 alternatives  
Hello everyone, I have a problem with UI locking.Why the UI is freezed? I think it shouldn't be until DownloadHotListAsync finish.Thanks a lot.What I have tried:private async void RetrieveHotlist(object sender, RoutedEventArgs e) //button click { await...
Please Sign up or sign in to vote.
26 Apr 2016
VR Karthikeyan
Check this,1. c# - A list view in WPF makes the UI frozen duing data binding - Stack Overflow[^]2. c# - Preventing wpf window from hanging - Stack Overflow[^]
Please Sign up or sign in to vote.
26 Apr 2016
George Swan
Could I suggest a few changes? After the await statement in the button click handler you are back on the dispatcher thread so you don’t need the Dispatcher BeginInvoke stuff. It is generally not a good idea to try to martial the threads yourself, you will get in a tangle. Leave all that to...
Please Sign up or sign in to vote.
27 Nov 2016
SrikantSahu
1 alternative  
I am trying to bind a gridview using EF 6.0 raw Sql query with Async, but the system goes on for endless execution and task.Result is never populated.What I have tried:protected void Page_Load(object sender, EventArgs e) { var task = LoadDataAsync(); task.Wait();...
Please Sign up or sign in to vote.
27 Sep 2017
Charlie Andrews
1 alternative  
Hello , I am trying to create an asp.net web api. This API will be called from a scheduler from cloud once every 15 minute where this API will look in db and Call an external third party web-service multiple times with different parameters.External service will just return true of false. ...
Please Sign up or sign in to vote.
27 Sep 2017
Richard Deeming
You're creating a series of Task objects, but never waiting for them to complete. The calling method will return before the work has finished. And if any of the tasks fails, it could end up taking down your entire process with an "unobserved exception" error. You should make the...
Please Sign up or sign in to vote.
8 Dec 2017
Member 13363439
Hi i have 3 method i want to load data like First come First Display.means which method execute first that should display in UI part .it should not wait for all method to be Complete. Here is My Sample code. this code is waiting for all function to be complete than page is loading.please help me...
Please Sign up or sign in to vote.
13 Mar 2018
Bala Manikanta Koorakula
I am new with Async and await using C# Programming. In WebAPI, we have created two API Controllers one with Async and await Programming and other is without that. We have done load testing using JMeter and we have got following results. Users Sync ...
Please Sign up or sign in to vote.
12 Apr 2018
rikidev
Hi guys with the code below I open a pool connection to sql server! My problem is that I should wait for the query to run, then return, how can I implement this? What I have tried: const DbConfig = require('../Config/DatabaseConfig.js'); const sql = require('mssql'); async function...
Please Sign up or sign in to vote.
20 Aug 2018
Waqar (Vicky)
1 alternative  
In my code behind i have a method OnFocusRequested which is called using Interface from my ViewModel when async search button command execute. the problem is that it is working fine when i just debug through each step from code. this code is not work in real time. I believe this is due to async...
Please Sign up or sign in to vote.
20 Aug 2018
Graeme_Grant
You can do it in code behind however can get messy if you have to do it for multiple controls. The answer is, where you need to use the code in more than one time, to use a behavior rather than code behind to encapsulate the code to avoid the same code in multiple places, reduces errors, and...
Please Sign up or sign in to vote.
11 Dec 2018
TABiSH777
Hi, you are on right track, you could use Backgroundworker for this purpose with ease, just remember some thing while working with multithread is that, we cannot access UI elements directly from another thread. And as entire code that's executed in Backgroundworker is in another thread we cannot...
Please Sign up or sign in to vote.
13 Dec 2018
Gerry Schmitz
Yes; you display the (new) .gif in the "ProgressChanged" handler (because it runs on the caller's UI thread versus DoWork which "is" the background worker thread). And you have to call "ReportProgress" (to invoke ProgressChanged) from DoWork; it doesn't run by itself.
Please Sign up or sign in to vote.
6 May 2019
badarhn
1 alternative  
hi all I'm testing the new Microsoft cognitive service example, the code below : GitHub - microsoft/Cognitive-Samples-VideoFrameAnalysis: A library with sample apps for continuous analysis of live video, using the Microsoft Cognitive Services Vision APIs.[^] when I try it returns an exception...
Please Sign up or sign in to vote.
8 Oct 2019
gouravkaila91
I am calling a c# web API using SSIS script task. The requirement is to pick request data from a table, convert each row to a request, call API for each request and store response in a table. I am looping around all rows of the table and calling API inside loop for one request (row) at a time....
Please Sign up or sign in to vote.
15 Sep 2020
hmdismail
I was writing some code for automatically generating report and appending it into a spreadsheet. The program runs periodically, each run generates a set of data and inserts it into the first empty row in a specific spreadsheet file. when writing...
Please Sign up or sign in to vote.
20 Aug 2015
Chris875
Please refer below for the several options to call a function with async/await.I put my questions below each option.Lets assume I have a 3rd party Dll and want to call a function of it asynchronously. Despite there is a function description one cannot know what actually happens...
Please Sign up or sign in to vote.
10 Jun 2014
Vi(ky
1 alternative  
HelloI write this code to search the blob items (text files) on the basis of there content. For ex : if I search for "Good", then the files that contains "Good or good" word the name of that files should appear in search result. My code is working but i want to optimize it.class...
Please Sign up or sign in to vote.
1 May 2014
123456789igor
Connect success. But how to send bytes, i don't knowprivate readonly Socket _server; public ServerSocket(IPAddress ipAddress, int port) { _server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _server.Bind(new...
Please Sign up or sign in to vote.
15 Feb 2015
Gaurav_Chaudhary
You can use "Async" and "Await" keywords ,if it's C# 4.5 or above.. Check this out https://i-msdn.sec.s-msft.com/dynimg/IC612215.png[^]Thanks
Please Sign up or sign in to vote.
27 Jul 2018
Vasilievski
2 alternatives  
Hi, My issue is the following : I have n Tasks that run in parallel. I want each Task to have its own continuation that uses the result. (Think of a UI update, for each finished task) If I were only using Framework 4.0 Task, I would use the ContinueWith on each task. But I want to use await...
Please Sign up or sign in to vote.
2 Aug 2018
Richard Deeming
You just need to await the task in the continuation methods. You'll probably also want to wait for all of the continuations to finish in your MainMethod. public async Task ReactToDoSomething(Task task) { int result = await task; // Do something here... } // Same for other "react...
Please Sign up or sign in to vote.
30 Jul 2018
George Swan
It may be a good idea to restructure your class to facilitate using the Task-based Asynchronous Pattern. I suggest that you change the signatures of some of your methods. Async void methods should be reserved for event handlers. My suggestion would be something like this. public async...
Please Sign up or sign in to vote.
11 Dec 2018
TheBigBearNow
1 alternative  
Hello all, I have a C# WPF application with a database of users. I have it so a user with the correct info can login and depending if they are an Admin or a Customer it will take them to their appropriate menu. Now I want to have a loading .gif while the program is checking the database for the...
Please Sign up or sign in to vote.
13 Dec 2018
TheBigBearNow
1 alternative  
So far I haven’t had luck with my loading gif image when I am loading/checking my database connection I click my login button and I get no errors in my login I start my gif but I also start it in the dowork and progress section im not sure which section is actually right I know not to mess wih...