async

Lightswitch html how to know when async iteration is done

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an async operation inside another async operation. I wonder how can i know when everything is done. Here is my code: msls.showProgress(msls.promiseOperation(function (operation) { screen.Staff.getConfirmedWaiters().then(function (result) { result.each(function (item) { item.getWaiter().then(function (result) { if (result.Gender == "Female") { confirmedGirls++; } }); }); operation.complete(confirmedGirls); }); }).then(function (result) { First I load the ConfirmedWaiters collection. Once it is completed I iterate every entity and load

Error using ES7 async/await with node, webpack and babel-loader

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use javascript ES7 syntax on the server using node.js with webpack and babel-loader (es2015 + stage-0 presets). I've gotten it to work with babel-node but when I run webpack I get the following error at the async keyword (9:22 is after the async keyword): ERROR in ./src/server.js Module parse failed: C:\dev\node-async-sample\src\server.js Unexpected token (9:22) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (9:22) I've put the code on github at https://github.com/qubitron/node-async

Async socket client using TcpClient class C#

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have implemented a socket client using TcpClient class. So I can send and receive data, everything works good. But I ask some of the guru's out there :) Is there something wrong with my implementation? maybe there is a better way of doing things. In particular, how do I handle disconnects? Is there some indicator (or maybe I can write one myself) that tells me that socket has disconnected? I also have looked into async await features of Socket class, but can't wrap my head around "SocketAsyncEventArgs", why is it there in the first place.

async vs threading, when to use each option?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: This page, http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx , in the thread section, says that a async method does not run in other thread, that if I want to use other thread, I would use Task.Run. So I understand that async and threading are two diferents things, and each option is good for some situations. I would like to know when is better to use async and when is better to use threading. Thanks. 回答1: You use threads when you have constant work to do. Either directly ofr with a custom written pool. And even then

Console ReadKey async or callback?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to do a press Q to quit thing in the console window. I dont like my current implementation. Is there a way i can async or use a callback to get keys from the console? 回答1: You can call Console.ReadKey() from another thread, so that it doesn't block your main thread. (You can use the .Net 4 Task or the old Thread to start the new thread.) class Program { static volatile bool exit = false; static void Main() { Task.Factory.StartNew(() => { while (Console.ReadKey().Key != ConsoleKey.Q) ; exit = true; }); while (!exit) { // Do stuff

Writing async service using cxf with java first approach

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to create a async webservice using cxf with java first approach. But i am unable to find any web resource/ website which tells me how to do this? Can you please tell how can I write a async webservice using CXF with java first approach? Thanks Shekhar 回答1: A simple alternative that can work in many situations: Execute a normal web service from the client. On the server, start the job in a new thread and return with a status like "job started" When the job is finished, let the server send the result back to the client. Advantages: It's

Task async controller method does not hit

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So, we've got an MVC project that has been upgraded through the different versions of MVC from 1 through to 4. Now we have a controller method: public async Task<ActionResult> IndexAsync() so if we go to http://somedomain.xyz/WhicheverController or http://somedomain.xyz/WhicheverController/Index , we are greeted with a 404. http://somedomain.xyz/WhicheverController/IndexAsync routes to the method just fine. What's gone wrong with our routing? 回答1: I believe that your example will work if you derive your Controller from AsyncController

struts2 Async Action

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Looking to use Struts2 with Serlvet 3.0 Async support. My first approach was to just handle to writing to the outputstream in the action and returning null. This however returns with a 404 "resource not available". I am attempting to adapt a Bosh servlet inside of a struts action, using ServletRequestAware, ServletResponseAware interfaces to inject the response. I am using the struts filter dispatcher. Not entirely sure if this is doable,but would be sure happy if someone else has managed to get async to work within a struts action. Perhaps

How do I call async methods in asp.net C# 4.0?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm aware that with .net 4.5 there is the await, async keywords that allows for easy calling of async methods. I 'm currently studying how to make async calls in C# 4.0. An example I want to is to make an async call where the datagrid is being databind. If you could provide me some links I would really appreciate it. 回答1: Have a look at using Tasks, this was available in .Net 4 and should help you. A simple example might look like this: public void MainFlow() { Task taskWork = Task.Factory.StartNew(new Action(DoWork)); //Do other work //Then

Execute parallel tasks with async/await

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to execute multiple async tasks in Silverlight. Documentation of the 3rd party package states I can use await Task.WhenAll() Unfortunately silverlight only have Task.WaitAll() and it is not awaitable. If I try to use it I get deadlock (I assume - because whole thing freezes) What is the proper pattern to use in async method? 回答1: For Silverlight I assume you're using the Microsoft.Bcl.Async package. Since this (add-on) package cannot modify the (built-in) Task type, you'll find some useful methods in the TaskEx type. Including WhenAll