synchronous

If MessageBox()/related are synchronous, why doesn't my message loop freeze?

戏子无情 提交于 2019-11-29 03:50:44
Why is it that if I call a seemingly synchronous Windows function like MessageBox() inside of my message loop, the loop itself doesn't freeze as if I called Sleep() (or a similar function) instead? To illustrate my point, take the following skeletal WndProc : int counter = 0; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: SetTimer(hwnd, 1, 1000, NULL); //start a 1 second timer break; case WM_PAINT: // paint/display counter variable onto window break; case WM_TIMER: //occurs every second counter++; InvalidateRect(hwnd, NULL, TRUE); /

Waiting for completion block to complete in an AFNetworking request

自作多情 提交于 2019-11-29 03:32:03
问题 I am making a JSON request with AFNetworking and then call [operation waitUntilFinished] to wait on the operation and the success or failure blocks. But, it seems to fall right though - in terms of the log messages, I get "0", "3", "1" instead of "0", "1", "3" NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://google.com"]]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; httpClient.parameterEncoding = AFFormURLParameterEncoding; NSDictionary *params

jQuery Deferred and Promise for sequential execution of synchronous and asynchronous functions

元气小坏坏 提交于 2019-11-28 21:30:06
If I want to have synchronous and asynchronous functions execute in a particular order I could use jQuery promise but it doesn't seem to work the way I'd expect it to work. Functions a,b and c should execute in that order when in a the deferred.resolve() is called I'd expect function b to be executed but all functions are executed immediately no matter if the resolve is called. Here is the code: function a(){ var deferred = $.Deferred(); setTimeout(function(){ console.log("status in a:",deferred.state()); //this should trigger calling a or not? deferred.resolve("from a"); },200); console.log(

NSURLConnection synchronous request on https

大城市里の小女人 提交于 2019-11-28 20:22:13
问题 Can anyone tell me the way how I can make a synchronous call to the https server? I am able to do asynchronous request on https server using following delegate methods. - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace and - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge but I need to do synchronous. 回答1: //Encoding the request NSData

Performance difference between Synchronous HTTP Handler and Asynchronous HTTP Handler

我的梦境 提交于 2019-11-28 20:18:44
Is there a performance difference between Synchronous HTTP Handler and Asynchronous HTTP Handler? IHttpHandler vs IHttpAsyncHandler Why choose one over another? What are the benefits? ASP.NET uses the thread pool to process incoming HTTP requests. When an IHttpHandler is called, a thread pool thread is used to run that request and the same thread is used to process the entire request. If that request calls out to a database or another web service or anything else that can take time, the thread pool thread waits. This means thread pool threads spend time waiting on things when they could be

Asynchronous or Synchronous calling of event handlers in javascript

喜欢而已 提交于 2019-11-28 19:29:34
Are event handlers executed synchronously or asynchronously in JavaScript? Here is JS bin which is showing that event handler is executed synchronously. Code: $('#toclick').bind('custom', function() { for (var i=0; i<100000; i++) {} console.log('Inside click handler'); }); $('#toclick').trigger('custom'); console.log('Outside click handler'); Output: Inside click handler Outside click handler This means if we trigger an event, the code below it won't be executed unless all the event handlers are executed. Am I right ? Bin with multiple event handlers That's correct. All event handlers are

Load and execute javascript code SYNCHRONOUSLY

浪尽此生 提交于 2019-11-28 18:36:04
Is there a way to load and execute a javascript file in a synchronous way just like a synchronous XMLHttpRequest? I'm currently using a sync XMLHttpRequest and then eval for this, but debugging that code is very difficult... Thanks for your help! Update I tried this now: test.html <html> <head> <script type="text/javascript"> var s = document.createElement("script"); s.setAttribute("src","script.js"); document.head.appendChild(s); console.log("done"); </script> </head> <body> </body> </html> script.js console.log("Hi"); Output: done Hi So it was not executed synchronously. Any idea to make "Hi

JS - Can't combine lib files

混江龙づ霸主 提交于 2019-11-28 18:09:06
I have multiple lib files in an an index.html file, that are loaded in proper sequence for an app I am running. <!-- example of some of them... --> <script src="/./sys/lib/jquery.min.js"></script> <script src="/./sys/lib/jquery.ui.min.js"></script> <script src="/./sys/lib/jquery.easing.min.js"></script> <script src="/./sys/lib/underscore.min.js"></script> <script src="/./sys/lib/handlebars.min.js"></script> <script src="/./sys/lib/backbone.min.js"></script> <script src="/./sys/lib/moment.min.js"></script> <script src="/./sys/lib/libs.extensions.js"></script> These run fine, they are already

How to force Sequential Javascript Execution?

人盡茶涼 提交于 2019-11-28 15:30:57
I've only found rather complicated answers involving classes, event handlers and callbacks (which seem to me to be a somewhat sledgehammer approach). I think callbacks may be useful but I cant seem to apply these in the simplest context. See this example: <html> <head> <script type="text/javascript"> function myfunction() { longfunctionfirst(); shortfunctionsecond(); } function longfunctionfirst() { setTimeout('alert("first function finished");',3000); } function shortfunctionsecond() { setTimeout('alert("second function finished");',200); } </script> </head> <body> <a href="#" onclick=

Load URL from txt File and load the URL in Browser Synchronous WebClient httpRequest

▼魔方 西西 提交于 2019-11-28 14:35:19
I started Windows Phone programming with this example from Microsoft: http://code.msdn.microsoft.com/wpapps/Hybrid-Web-App-75b7ef74/view/SourceCode The app only displays the browser and load a URL. Now I want to load an other URL directly from a .txt file. For example: http://www.test.de/appurl.txt and then I want to load the URL in the Windows Phone App. --> For example: http://anotherserver.de/index.html?mobileApp My problem is, that the URL have to load synchronous and not asynchronous. I implement a AutoResetEvent, but it don´t work... Hope somebody can help me, thx! Here is my Code: