async-await

Multiple await on same task may cause blocking

走远了吗. 提交于 2019-12-20 04:06:51
问题 It should be careful to use several awaits on same Task. I have encountered with such situation while trying to use BlockingCollection.GetConsumingEnumerable() method. And ends up with this simplified test. class TestTwoAwaiters { public void Test() { var t = Task.Delay(1000).ContinueWith(_ => Utils.WriteLine("task complete")); var w1 = FirstAwaiter(t); var w2 = SecondAwaiter(t); Task.WaitAll(w1, w2); } private async Task FirstAwaiter(Task t) { await t; //await t.ContinueWith(_ => { }); Utils

Task is not completing second time [Intermittent Issue] – Async/ Await

我与影子孤独终老i 提交于 2019-12-20 03:34:16
问题 I have a WebBrowser control is Windows Forms project. It navigates through all the urls available in “MyTableTest.html”. There are four urls in this page and the webbrowser goes through each one – one by one. Once it reaches the last one it should go to the first again. It works fine in the first iteration – but not going to the urls in the second iteration. This is an intermittent issue - certain times it works. It seems (from the log) that he awaited task is not completed. What can be done

Task is not completing second time [Intermittent Issue] – Async/ Await

南笙酒味 提交于 2019-12-20 03:34:06
问题 I have a WebBrowser control is Windows Forms project. It navigates through all the urls available in “MyTableTest.html”. There are four urls in this page and the webbrowser goes through each one – one by one. Once it reaches the last one it should go to the first again. It works fine in the first iteration – but not going to the urls in the second iteration. This is an intermittent issue - certain times it works. It seems (from the log) that he awaited task is not completed. What can be done

does async/await method run in the same thread as caller?

梦想与她 提交于 2019-12-20 03:33:11
问题 I have read that async/await methods runs in the same thread as caller and I saw it in a WPF application but while testing a code in console application I see it is running in a different thread than caller. Have I missed something? 回答1: Have I missed something? Sort of. await doesn't know anything about threads . It causes the code after the await keyword (by default) to run in the same SynchronizationContext as the caller, if it exists. In the case of a WPF Application, the current

Looping Async Task List in C#

主宰稳场 提交于 2019-12-20 03:17:49
问题 I am trying to parse data from several websites continuously. I would like this action to be preformed individually in a loop in an asynchronous manner until the program is closed. I am not sure what the structure should be for this kind of logic. Right now I am following this pattern. async public void ParseAll(List<Site> SiteList) { List<Task> TaskList = new List<Task>(); foreach(Site s in SiteList) { TaskList.Add(s.ParseData); } await Task.WhenAll(TaskList) } The issue is that if I

React.js component life cycle, state behavior and asynchronous nature of JavaScript

爱⌒轻易说出口 提交于 2019-12-20 03:01:12
问题 I have an issue with the expected result and the actual result. Even though the fetchData() and fetchnumberOfCommits() methods are called from the componentWillMount() still the array has no data . But at the end, the render method is called twice, where the array has got data from the API. I called the setState() method in both the above-mentioned methods where it calls the render method. My problem is why does the array does not get data as soon as the two methods are called? and at what

xUnit async tests shows up as “External” in VS2015

こ雲淡風輕ζ 提交于 2019-12-20 02:52:46
问题 I have problems with all my async xUnit tests showing up as External in the Test Explorer in VS2015. They will still run when calling Run All in the test explorer, but as they are considered external almost all of the VS2015 integration does not work, e.g. the navigation (click in test explorer to get to test) is not working, the Run/Debug Tests in the context menu never triggers the test, test status icons doesn't show and Code Lens won't find these tests. The async tests are using the

Understanding Async/Await patterns in JavaScript

那年仲夏 提交于 2019-12-20 02:26:34
问题 I'm relatively new to JavaScript programming, and so callbacks have been giving me trouble. I'm using a framework that supports the "async/await" syntax from ES7 (Meteor), but I'm having some difficulty understanding exactly how I can implement an asynchronous function that calls other functions. What I want to do: The user enters a URL, data is fetched from the URL, processed, and put into a database. I want this to occur in a non-blocking manner, so that the user can continue to use the

To run or not run ConfigureAwait(false) with both services and activities with Xamarin Android ver 8, .net Standard

偶尔善良 提交于 2019-12-20 01:52:07
问题 I came across articles below regarding when and where to use ConfigureAwait(false) , but cannot get an answer. You Don’t Need ConfigureAwait(false), But Still Use It in Libraries, and UI apps. (e.g. Xamarin, WinForms etc) https://blog.stephencleary.com/2017/03/aspnetcore-synchronization-context.html This link says opposite answer Best practice to call ConfigureAwait for all server-side code When correctly use Task.Run and when just async-await My questions: Scenario 1 : The code below is

Xamarin.Forms - BeginInvokeOnMainThread for an async Action

瘦欲@ 提交于 2019-12-20 01:34:54
问题 I am familiar with the rules about updating UI elements on the UI thread using the Device.BeginInvokeOnMainThread, however I have an operation that needs to be run on the UI thread that is actually a Task. For example, the Push/PopAsync methods on XLabs.Forms.Mvvm seem to behave incorrectly on iOS unless they are invoked on the UI thread. There is also another example in the Acr.UserDialogs library for displaying toasts etc. I know that making an Action async is basically creating an async