开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: async / await example for the CSharp API?


 

开云体育

Read this article, another one from the estimable Stephen Toub:

?

?

The bottom line is that if you're in a console app, by default SynchronizationContext.Current simply passes continuations to the thread pool, which means the continuation may not run on the same thread as the body of the task. But you can 'do things' to modify this behaviour.

?

Note that this article is rather old (2012), and the async/await mechanisms have advanced somewhat since then, so you should make efforts to find more up-to-date information. For example, C# 7.1 introduced the ability for a program to have an async Main method, for which you can find plenty of info online (I'm not suggesting that you need this in your program, merely that you need to be aware of how things are evolving).

?

Please note, however, that this group is not intended for questions about programming techniques, so in general it would be more appropriate to ask such questions elsewhere, such as StackOverflow.

?

?

From: [email protected] <[email protected]> On Behalf Of regtrash1234@...
Sent: 02 April 2021 16:24
To: [email protected]
Subject: Re: [TWS API] async / await example for the CSharp API?

?

Just a follow up question on this:
In the?backend\IBClient.cs there's a property?SynchronizationContext sc?which in the constructor is set to?SynchronizationContext.Current
Is this due to the application being a WinForms application or is this also required for a console application? Thanks :-)

Join [email protected] to automatically receive all group messages.