synchronous

How I can implement sync calls to WCF services in SIlverlight?

纵然是瞬间 提交于 2019-11-28 12:58:59
Sometimes I need to call WCF service in Silverlight and block UI until it returns. Sure I can do it in three steps: Setup handlers and block UI Call service Unblock UI when everything is done. However, I'd like to add DoSomethingSync method to service client class and just call it whenever I need. Is it possible? Has anyone really implemented such a method? UPDATE: Looks like the answer is not to use sync calls at all. Will look for some easy to use pattern for async calls. Take a look at this post (taken from comments) for more. Here's the point; you shouldn't do sync IO in Silverlight. Stop

Meteor wrapAsync syntax

蓝咒 提交于 2019-11-28 12:31:54
How do I use the Meteor wrapAsync ? Below is what I am trying to do if (tempTreatment.groupId === undefined) { // create new group Meteor.wrapAsync(Meteor.call('createTreatmentGroup', salon, tempTreatment.groupName, tempTreatment.groupName)); // get group id var getGroup = Meteor.wrapAsync(Meteor.call('getTreatmentGroup', salon, tempTreatment.groupName)); console.log(getGroup); tempTreatment.groupId = getGroup._id; } I want to run these two Meteor.call functions synchronosly but I get undefined on console.log(getGroup); which shuold just return an object. Meteor.wrapAsync is a server-side API

Promise is synchronous or asynchronous in node js

不羁岁月 提交于 2019-11-28 12:07:53
I have lot of confusion in promise. It's a synchronous or asynchronous ? return new Promise (function(resolved,reject){ //sync or async? }); The function you pass into the Promise constructor runs synchronously, but anything that depends on its resolution will be called asynchronously. Even if the promise resolves immediately, any handlers will execute asynchronously (similar to when you setTimeout(fn, 0) ) - the main thread runs to the end first. This is true no matter your Javascript environment - no matter whether you're in Node or a browser. console.log('start'); const myProm = new Promise

Is map() in javascript synchronous?

拟墨画扇 提交于 2019-11-28 12:01:18
Function is : [1,2,3].map( function (item) { console.log(item); //return 'something'; }); My expected behaviour is getting only 1 as output, unless i uncomment the //return 'something' But i really get 1 2 3 What am i doing wrong ? UPDATE: i am testing that with nodejs. i really dont understand. var async = require("async"); [1,2,3].map( function (item) { console.log(item); //return 'something'; }); async.map([1,2,3], function (item,callback) { console.log(item); //callback(null,true) }, function (err,result) { console.log(result); } ); Both return the same 1 2 3 And i really would like to

Make synchronous function in javascript? [duplicate]

自作多情 提交于 2019-11-28 11:13:02
This question already has an answer here: How should I call 3 functions in order to execute them one after the other? 10 answers I wanna synchronized functions just like jQuery's $.ajax({ .., async: false, .. }); . function A() { lalala .. }; function B() { dadada .. }; function C() { .. }; , those all including some effect like fadeIn, Out, slide... etc. However I just found if those functions called like below.. A(); B(); C(); All effect start at almost same time. In my understanding, this happens because the function called synchronously but it doesn't mean that function B() started after

Convert Blob to binary string synchronously

元气小坏坏 提交于 2019-11-28 08:56:54
问题 I'm trying to put image in clipboard when user copies canvas selection: So I thought the right way would be to convert canvas tu dataURL, dataURL to blob and blob to binary string. Theoretically it should be possible to skip the blob, but I don't know why. So this is what I did: function copy(event) { console.log("copy"); console.log(event); //Get DataTransfer object var items = (event.clipboardData || event.originalEvent.clipboardData); //Canvas to blob var blob = Blob.fromDataURL(_this

Is Javascript synchronous when manipulating the DOM?

本秂侑毒 提交于 2019-11-28 07:47:05
问题 I have a form with an input of type field. I have several radiobuttons, and depending on which of them I click, the value in the input type field will be updated. After that, I will call a Javascript function to perform certain action, and the function will use the updated quantity (text) in the input field. Of course, it is more secure to pass that quantity to the function itself, but could I rely on Javascript first updating the DOM, displaying the update input field value, and with that,

Javascript Promises with FileReader()

半腔热情 提交于 2019-11-28 06:59:26
I have the following HTML Code: <input type='file' multiple> And Here's my JS Code: var inputFiles = document.getElementsByTagName("input")[0]; inputFiles.onchange = function(){ var fr = new FileReader(); for(var i = 0; i < inputFiles.files.length; i++){ fr.onload = function(){ console.log(i) // Prints "0, 3, 2, 1" in case of 4 chosen files } } fr.readAsDataURL(inputFiles.files[i]); } So my question is, how can I make this loop synchronous ? That is first wait for the file to finish loading then move on to the next file. Someone told me to use JS Promises. But I can't make it to work. Here's

How to make a synchronous request using Alamofire?

柔情痞子 提交于 2019-11-28 02:55:50
问题 I am trying to do a synchronous request using Alamofire . I have looked on Stackoverflow and found this question: making an asynchronous alamofire request synchronous. I saw that the accepted answer uses completion to make Alamofire request synchronous but I cannot make it to work. This is my simplified code: func loadData(completion: (Bool)) -> (Int, [String], [String], [String]){ Alamofire.request(url!, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil)

jQuery ajax Page Reload

♀尐吖头ヾ 提交于 2019-11-28 01:55:12
问题 We are making multiple ajax requests to "save" data in a web app, then reload the page. We have run into a situation where (since requests are made asynchronously) the page is reloaded while or before the ajax calls are completed. The simple solution to this was to make the ajax calls with the "async": false option on, forcing synchronous calls. This seems to work, however dialog box code that runs BEFORE any calls are executed delay in running. Any advice is greatly appreciated! Also it