async-await

How to implement Command Pattern with async/await

人走茶凉 提交于 2021-01-24 05:21:33
问题 i'm currently upgrading some existing code for use by windows universal and am struggling to convert a command pattern to work with the new async/await functionality. I have a command scheduler class that runs within its own thread and processes commands that have been added to its queue. The method in question looks like this: private List<ICommandItem> _items; private void ProcessCommands() { while(_items.count > 0) { _items[0].Execute(); _items.RemoveAt(0); } } My problem is that some of

How to implement Command Pattern with async/await

旧街凉风 提交于 2021-01-24 05:20:51
问题 i'm currently upgrading some existing code for use by windows universal and am struggling to convert a command pattern to work with the new async/await functionality. I have a command scheduler class that runs within its own thread and processes commands that have been added to its queue. The method in question looks like this: private List<ICommandItem> _items; private void ProcessCommands() { while(_items.count > 0) { _items[0].Execute(); _items.RemoveAt(0); } } My problem is that some of

JavaScript/Angular 1 - Promise.all to async-await

£可爱£侵袭症+ 提交于 2021-01-23 07:47:45
问题 I assign two calls to the web service in two variables in referencesPromise and contactTypesPromise $onInit() (I can create a new method for that, if needed) $onInit() { const referencesPromise = this.ReferenceService.getMultipleReferences(this.AgentReferences) const contactTypesPromise = this.ContactService.getContactTypes() Promise.all([referencesPromise, contactTypesPromise]).then((responses) => { this.references = responses[0] this.contactTypes = responses[1] const stateParams = this.

How to await inside setInterval in JS?

风流意气都作罢 提交于 2021-01-21 03:55:25
问题 I have a code segment that looks like this: async function autoScroll(page, maxDate = null) { await page.evaluate(async () => { await new Promise(async (resolve, reject) => { try { const scrollHeight = document.body.scrollHeight; let lastScrollTop = 0; const interval = setInterval(async () => { window.scrollBy(0, scrollHeight); const scrollTop = document.documentElement.scrollTop; let lastDate = null; if (maxDate) { const html = new XMLSerializer().serializeToString(document.doctype) +

How to await inside setInterval in JS?

孤街醉人 提交于 2021-01-21 03:53:05
问题 I have a code segment that looks like this: async function autoScroll(page, maxDate = null) { await page.evaluate(async () => { await new Promise(async (resolve, reject) => { try { const scrollHeight = document.body.scrollHeight; let lastScrollTop = 0; const interval = setInterval(async () => { window.scrollBy(0, scrollHeight); const scrollTop = document.documentElement.scrollTop; let lastDate = null; if (maxDate) { const html = new XMLSerializer().serializeToString(document.doctype) +

Javascript WebWorker - Async/Await

爱⌒轻易说出口 提交于 2021-01-20 20:47:22
问题 I am trying to offload long running process that blocks my UI. The WebWorker approach appears to be the best approach to this situation. However, one of the libraries that I need to use has async/await. The WebWorker has a limited JS API and does not appear to have async/await. Is there a way to use Promises inside of a WebWorker? Error ReferenceError: __awaiter is not defined Regards, Daniel Update: Adding an __awaiter lead to the Promise not being recognised. var __awaiter = (this && this._

Javascript WebWorker - Async/Await

会有一股神秘感。 提交于 2021-01-20 20:46:06
问题 I am trying to offload long running process that blocks my UI. The WebWorker approach appears to be the best approach to this situation. However, one of the libraries that I need to use has async/await. The WebWorker has a limited JS API and does not appear to have async/await. Is there a way to use Promises inside of a WebWorker? Error ReferenceError: __awaiter is not defined Regards, Daniel Update: Adding an __awaiter lead to the Promise not being recognised. var __awaiter = (this && this._

How can I prevent one async method from monopolizing another?

依然范特西╮ 提交于 2021-01-07 06:31:33
问题 In my UWP app, I've got an async method (event handler) that calls another async method, which attempts to insert a record into a database. I'm getting an exception in the insertion attempt, and am trying to sherlock why it's happening. So I put a breakpoint in the InsertMapRecord() method, on the first "using" line: using (SqliteConnection conn = new SqliteConnection(connStr)) When I reach that breakpoint, I hit F10, but instead of taking me to the next line in the Insert method, it takes me

How to use Pomelo.EntityFrameworkCore.MySql provider for ef core 3 in async mode properly?

为君一笑 提交于 2021-01-07 03:56:03
问题 We are building an asp.net core 3 application which uses ef core 3.0 with Pomelo.EntityFrameworkCore.MySql provider 3.0. Right now we are trying to replace all database calls from sync to async, like: //from dbContext.SaveChanges(); //to await dbContext.SaveChangesAsync(); Unfortunetly when we do it we expereince two issues: Number of connections to the server grows significatntly compared to the same tests for sync calls Average processing speed of our application drops significantly What is

How to use Pomelo.EntityFrameworkCore.MySql provider for ef core 3 in async mode properly?

☆樱花仙子☆ 提交于 2021-01-07 03:55:09
问题 We are building an asp.net core 3 application which uses ef core 3.0 with Pomelo.EntityFrameworkCore.MySql provider 3.0. Right now we are trying to replace all database calls from sync to async, like: //from dbContext.SaveChanges(); //to await dbContext.SaveChangesAsync(); Unfortunetly when we do it we expereince two issues: Number of connections to the server grows significatntly compared to the same tests for sync calls Average processing speed of our application drops significantly What is