async

What is the type VoidTaskResult as it relates to async methods?

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've been using async (and .Net 4.5 really) for the first time recently, and I've come across something that has me stumped. There isn't much information about the VoidTaskResult class that I can find on the Net so I came here to see if anyone has any ideas about what is going on. My code is something like the following. Obviously, this is much simplified. The basic idea is to call plugin methods, which are asyncronous. If they return Task, then there is no return value from the async call. If they return Task<>, then there is. We

Can&#039;t get throws to work with function with completion handler

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to add a throws to my existing function with a completion handler but I keep getting a warning saying no calls throwing functions occur within try expression . In the section where I throw the errors, I get an error saying invalid conversion from throwing function of type '() throwing -> Void' to non-throwing function type. enum LoginError: ErrorType { case Invalid_Credentials case Unable_To_Access_Login case User_Not_Found } @IBAction func loginPressed(sender: AnyObject) { do{ try self.login3(dict, completion: { (result) -> Void

System.IO.IOException: &#039;The process cannot access the file &#039;@.txt&#039; because it is being used by another process.&#039;

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to programming and I have a question. If I have two functions, one creates a text file and writes into it, while the other opens the same text file and reads from it. The error I get is: System.IO.IOException: 'The process cannot access the file '@.txt' because it is being used by another process.' I have tried setting seperate timers to each of the functions but it still does not work. I think the best way would be that the function two does not start until function one ends. Can you help me achieve this? Thank you very much! Mike

Make WebAPI actions async?

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got a question about whether it's beneficial to use async/await on WebAPI / MVC Controller AJAX requests. Say I've got this AngularJS app that talks to a WebAPI backend and I want to get some data. I do some AJAX call to WebAPI and wait for the results. In terms of the client, this is of course Async. Would it now be beneficial for the server if I was to make these actions Async? EDIT I just found this: http://www.dotnetcurry.com/showarticle.aspx?ID=948 - saying it IS EDIT - attempt to clarify Let me try to be more clear. Will the

Async foreach in nodejs

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In node.js, I know array.forEach is blocking. I need to loop through an array and build a string like this: var rarray = ['test', 'test2']; var rstring = ''; rarray.forEach(function(e, i){ rstring = rstring + i + e; }); return rstring; how do i do it asynchronously? 回答1: In such a case, you probably don't need to transform this code into its async version. Hypothetically, or for very very large arrays, heres's a way to transform your code into something asynchronous, or at least something that will get back to the main event loop

Protractor - Wait for async promise before doing next

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: First of all, I've already checked various post and blogs concerning that point and I still can't figure out how to make it correctly. I have tried many different combinaison of : browser wait protractor.controlFlow().execute protractor.controlFlow().await( ...Still no success.. My problem Within my beforeEach function, I'd like to call a protractor promise and wait for it to resolve before performing the rest of my code. My Code I've prepared this simple test for anyone willing to help me describe ( 'testAsync' , function () {

How to call any method asynchronously in c#

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Could someone please show me a small snippet of code which demonstrates how to call a method asynchronously in c#? 回答1: If you use action.BeginInvoke(), you have to call EndInvoke somewhere - else the framework has to hold the result of the async call on the heap, resulting in a memory leak. If you don't want to jump to C# 5 with the async/await keywords, you can just use the Task Parallels library in .Net 4. It's much, much nicer than using BeginInvoke/EndInvoke, and gives a clean way to fire-and-forget for async jobs: using System

dispatch_async vs. dispatch_sync using Serial Queues in Grand Central Dispatch

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: OK, I love Grand Central Dispatch and after using it with relative success but this is something I don't fully understand. Suppose I have created my own serial queue using dispatch_queue_t myQueue; myQueue = dispatch_queue_create("myQueue", NULL); After that I do this: dispatch_async(myQueue, ^{ [self doStuff1]; }); // and a few lines later... dispatch_sync(myQueue, ^{ [self doStuff2]; }); The first dispatch is async. So, it will be done concurrently, right? How can that be if myQueue is serial? How can a serial queue do things in parallel

Async/Await Class Constructor

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: At the moment, I'm attempting to use async/await within a class constructor function. This is so that I can get a custom e-mail tag for an Electron project I'm working on. customElements.define('e-mail', class extends HTMLElement { async constructor() { super() let uid = this.getAttribute('data-uid') let message = await grabUID(uid) const shadowRoot = this.attachShadow({mode: 'open'}) shadowRoot.innerHTML = ` A random email message has appeared. ${message} ` } }) At the moment however, the project does not work, with the following error:

Use await outside async

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to make the javascript await keyword work outside async functions? I would like to be able to freeze the entire call-stack (instead of just the rest of the async function), to be resumed once the particular promise returns a value. Sadly a powerful await like that is currently gimped or not implemented yet. I tried to make nodent.js work, but due to my custom loader and dynamic functions it's unfortunately impractical. 回答1: Given you are looking for a hack, not a proper promise-based concurrency solution, have a look at node