javascript,asynchronous,callback
The success function is a callback, meaning it can be called whenever. In this case, it is being called after the ajax call, and return result; is being called before the ajax call, meaning result is not assigned before returning it, which is why it's always undefined. One way I...
After thinking I changed logic how my child model update triggers update on Status. Instead of using an after_touch callback in parent, I moved all the code to a callback belonging to the Batch. I had also to change type of callback being used to after_save to have a batch...
You need to pass a function reference to one. So here the solution could be is to pass an anonymous function as the callback to one which will call two with three as the callback reference. function testCallBack() { one(function(){ two(three); }); } Demo: Fiddle...
javascript,node.js,express,callback
You are dealing with asynchronous code. There are a couple ways to solve this problem. With A Promise // api.js var Promise = require('bluebird'); var request = require('request'); var getP = Promise.promisify(request.get.bind(request)); exports.getUser = function(accessToken) { return getP({ uri: URL + '/user/me/', headers: {Authorization: 'bearer ' + accessToken}, json: true...
java,c++,c++11,callback,abstract-class
The C++11 solution would be to have Button look something like this. I'm skipping the string and DialogButtonType parameters for brevity: class Button { public: template <typename F> Button(F&& f) : cb(std::forward<F>(f)) { } void callback() { cb(); } private: std::function<void()> cb; // type-erased functor for ANY callable // that...
cordova,callback,phonegap-plugins,nfc
Based on Michael Roland's answer, I got a better understanding of how it works so I constructed a function to manage my NdefListener callbacks. var currentListenerCallback; //global, this one is. function replaceCurrentNdefListener(newCallback) { nfc.removeNdefListener( currentListenerCallback, function() { console.log('successfully removed listener callback: writeTag()'); currentListenerCallback = newCallback; //make the new callback the...
$(this).data("callback") returns a string. You want to find the actual function identified by the string returned by $(this).data("callback"). If the function is global, you can do window[$(this).data("callback")] to refer to window.callbackFN. If the function is not global (i.e., it is local to a function), you may be able to refer...
javascript,arrays,foreach,callback
forEach takes a callback that accepts 3 arguments, the array element, the index, and the array. You only need the first. Wrap your call to draw() in an anonymous function and invoke it on the element from the function call. arr.forEach(function(elem) { elem.draw(); }); ...
javascript,angularjs,callback,control-flow
Examine your callbacks. function(req, res, next){ model.getMessages(function(results){ return results; } Your serverside code will return undefined. It will run model.getMessages...and while that is happening, since there is nothing left to do, just return out. That's why it looks like it's happening too quickly. Might want to res.send back inside a...
javascript,jquery,callback,argument-passing
No, you cannot use bind to partially apply non-initial parameters (and there's no flip). Just use a function expression: $.getJSON('getAllTerminals.json', function(data) { renderTerminalsOnMapAndFitBounds.call({ index:globalRequestCounter++, navigateToTypedText:true }, data, true); }); If you have to use bind, either change the parameter order of renderTerminalsOnMapAndFitBounds, or make it accept that updateSelectedTerminals parameter as...
you could use change listener or beforeEndOperation listener, and use something like editor.on("beforeEndOperation", function(e) { if (editor.curOp.docChanged && editor.curOp.command.name == "insertstring") { var pos = editor.getCursorPosition(); var token = editor.session.getTokenAt(pos.row, pos.column); if (token && token.type == "keyword") { alert( "Hey there!", "This is me, the most annoying editor feature evar.",...
javascript,ember.js,callback,promise,ic-ajax
Your problem has nothing to do with Ember or transitions; it's all about this handling. The simplest solution is just .then(transitionToHome.bind(this)); Putting transition method inside the controller You could also consider putting transitionToHome inside the controller as a method. Then, you could call it as in the following: export default...
javascript,jquery,callback,promise
$.getScript() returns a jqXHR promise, which can be assigned for later use. You could write ... var somejsPromise = $.getScript('some.js', function() { //Call some function in some.js }); ... but it's better not to use the global namespace, so you could use the jQuery namespace : $.somejsPromise = $.getScript('some.js', function()...
python,c++,callback,wrapper,cython
You can't easily: a C++ function pointer just stores the location in memory where the code for that function begins (or something similar, implementation specific) while a Python function is a full Python object with a dictionary storing the bytecode, (possibly the uncompiled Python code), documentation strings and a few...
Your printResult function runs asynchronously. All UI changes must be dispatched to the main queue To get back to the main queue use: dispatch_async(dispatch_get_main_queue(), ^{ doneFunction(…) }); inside your completion block of the POST request...
I had similar problem, you can convert this as below. var myClass = MyClass() var classPtr = unsafeBitCast(myClass, UnsafePointer<Void>.self) and your function, func someSwiftClass(voidPointer: UnsafeMutablePointer<Void>) { } If you want to declare constant pointer use UnsafePointer<T> and when your pointer is not constant use UnsafeMutablePointer<T> In C constant pointer -...
android,callback,baseadapter,retrofit
I have found the problem. This is the solution public class AsmReactionsAdapter extends BaseAdapter{ @Override public View getView(int position, View convertView, ViewGroup parent) { final AnswersAsm answer = getItem(position); ViewHolder viewHolder; if (convertView != null) { viewHolder = (ViewHolder) convertView.getTag(); } else { convertView = from(context).inflate(R.layout.asm_reaction_item, parent, false); viewHolder =...
swift,callback,associated-types
i think swift is buggy at this place. maybe you can use protocol Proto { typealias ItemType func register(tag: String, cb: (Self, Self.ItemType)->()) func unregister(tag: String, cb: (Self, Self.ItemType)->()) } class Foo : Proto { func register(tag: String, cb: (Foo, Int)->()) { } func unregister(tag: String, cb: (Foo, Int)->()) {...
javascript,node.js,callback,promise,q
I don't even see why you particularly need promises for this. function myHandler(req, res) { var dataChunks = [], dataRaw, data; req.on("data", function (chunk) { dataChunks.push(chunk); }); req.on("end", function () { dataRaw = Buffer.concat(dataChunks); data = dataRaw.toString(); console.log(data); var filePath = 'C://test.txt'; var writeStream = fs.createWriteStream(filePath, {flags: 'w'}); writeStream.write(data); writeStream.on('finish',...
javascript,asynchronous,meteor,callback
you could remove the conditionals and instead implement Javascript Promises they're fun and fancy plus they eliminate callback hell and provide a readable top down format: http://jsfiddle.net/4v29u4do/1/ This fiddle shows how you could use promises to wait for async callbacks instead of conditional if statements With promises you can return...
javascript,node.js,asynchronous,express,callback
This will resolve the problem: var server = app.listen(8000, function(){self.consolePrint(server)}); ...
javascript,parameters,callback
You can pass an anonymous function which can call the function with required parameters talk('John', hello, function(){ weather('sunny') }, goodbye); function talk(name) { console.log('My name is ' + name); var callbacks = [].slice.call(arguments, 1); callbacks.forEach(function(callback) { callback(); }); } function hello() { console.log('Hello guys'); } function weather(meteo) { console.log('The weather...
javascript,templates,meteor,callback,helper
There is a pending feature for adding animation/transition support for UI changes (referenced here) As an interim solution, you can use Blaze UI hooks. There are quite a few packages that use them. example here and here In general, , Meteor way is to reduce the amount of boiler plate...
javascript,jquery,class,object,callback
EDIT Actually, my first solution does not work because the context of the callback is the element, not the object. Here is the working code and a jsfiddle: function Waves(selector){ this.selector = selector; this.animateWaves = function(forward,backward,speed){ var self = this; $(selector).velocity({translateX: forward},speed); $(selector).velocity({translateX: backward}, speed, function () { self.animateWaves(forward,backward,speed); });...
Pretty much the same as you'd do it in Java. In your library, define a pure virtual class (more-or-less analogous with Java interface) of the handler. class somethinghandler { public: virtual void somethinghappened(<stuff that happened>) = 0; } And define and implement a class to watch for the event and...
angularjs,callback,scope,synchronization,promise
The callback is called as soon as the $resource finishes what it is doing. This doesn't have to be in the Angular digest cycle. The promise is resolved in the angular digest cycle. When you call $rootScope.$apply() For more see: Resolving promises without a digest cycle...
In your current implementation you can do this in PHP >= 5.4.0: $calculationSquare = userNumber($number)[0]; $calculationCube = userNumber($number)[1]; Or better, this would only call the function once: $result = userNumber($number); $calculationSquare = $result[0]; $calculationCube = $result[1]; Or maybe even better, use list() to assign array values to individual variables: list($calculationSquare,...
javascript,node.js,callback,mongoose
If you make that the first parameter instead, you can use .bind(). token.save(saveCallBack.bind(null, email_address)); var saveCallBack = function(email_address, err, model){}; ...
facebook,heroku,oauth,callback,passport-facebook
Did you add the callback URL to the app's settings? You have to add the site URL as that in the facebook developer app settings for it to allow facebook to make callbacks to any particular website. Should be under either basic settings on site URL or advanced settings on...
java,android,animation,callback,translate-animation
Please try: view.animate().translationY(100).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { closeFragmentAnimationComplete(); } @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }); ...
c++,sqlite,design-patterns,callback
The way I would do it is to make the callback a private static member function and basically do what you did. Like this: class SqliteAccessor { public: bool has_table(const std::string dbName, const std::string tblName); private: static int callback(void *NotUsed, int argc, char **argv, char **azColName); bool m_hasTable; }; int...
Since you use $this->my_array and the function has the keyword public, I'm going to assume these two methods are in a class definition, so you also have to define, that you want to call a class method and not a normal function. This means you have to change: usort($this->my_array, 'cmp');...
javascript,node.js,api,callback
I have no clue really what you're trying to accomplish, instead of going thenRunThisFunction(); thenRunThisFunction(); thenRunThisFunction(); thenRunThisFunction(); thenRunThisFunction(); Just invoke them by their names, remove the argument from them getRhyme(); getDef(); What you're doing will never work, you're trying to call thenRunThisFunction as if it actually exists, it's an argument...
javascript,node.js,callback,promise,q
I had similar issues and I realized later it was because of Q. In my opinion Q has a messy API and it's cumbersome to use with very few simple examples. I recommend trying any other library, though I do recommend Bluebird. With Bluebird you could do the following: var...
javascript,function,callback,add,indices
You are returning too early, the first iteration through the loop is going to end the function call. It looks like you want to use a callback to do the merge work, much like you would with .filter, .sort of Array. If that is the case, you do either the...
javascript,jquery,ajax,callback,this
In this context - this is not an element. Save before ajax call this to self variable. Like var self = this; $.ajax({ ... success: function(response) { var output = response[1].data; alert(output); $(self).hide(); } }); ...
If I am understanding you correctly: private static readonly List<Task> weatherTasks = new List<Task>(); public static void GetCurrentLocationWeatherAsync(double latitude, double longitude, Action<WeatherData> callback) { // ... weatherTasks.Add(asynClient.OpenReadTaskAsync(new Uri(url))); } public static void WaitForAllWeatherCalls() { Task.WaitAll(weatherTasks.ToArray()); weatherTasks.Clear(); } Create a list of tasks then change the OpenReadAsync to OpenReadTaskAsync and put...
javascript,angularjs,cordova,callback,listener
You can't directly assign to $scope.myID until your service is ready. You need to somehow provide a callback that will assign the correct value to your $scope model. You could do this either by making the service return a Promise somewhere that resolves when it's ready, or by emitting an...
java,interface,callback,return-value
It is quite unclear what you ask but ill give it a shot. Interfaces are a way to allow objedcts to follow a specific patern, They come handy for instance whern i have an interface called "Listener" and 5 implementations: ActionListener, MouseListener, KeyListener, CloseListener, StateChangeListener. If i want to have...
javascript,arrays,json,callback
If you're asking what I think you're asking and you would like to show a random video, then you may want to consider generating a random number from an array of videos. var videos = [ // Place any and all videos in this array {"video": {"mp4": "http://c0026122.cdn1.cloudfiles.rackspacecloud.com/193807.mp4", "webm": "http://5860e9e4db2f4cebe1e6-cc12bb9b5e092d34d0fadb7ce5f280a3.r47.cf1.rackcdn.com/193807.webm",...
c++,c,class,callback,global-variables
This answer is specific to the GLFW library, and is not trying to answer the more general programming language question. However, you migh find this useful as it addresses the issue you are really trying to solve. GLFW does support a way which allows passing user-specific data to the callback...
javascript,node.js,mongodb,callback,mongoose
Yes, they are the same thing. According to the 4.0 release notes: #2552: Upgraded mongodb driver to 2.0.x. Mongoose is a wrapper layer on top of the MongoDB node driver. The mongodb driver recently released version 2.0, which includes numerous performance and usability improvements. The new driver, however, introduces a...
node.js,mongodb,callback,mongoose
When you don't pass a done argument to your test callback, mocha doesn't wait for its completion, but it still executes it. You did: it('should allow delete of the user created', function () { // your test }); So, that's why your user data is being deleted, but you can't...
ios,objective-c,callback,block
This is your function typedef void(^VOIDCALLBACK)(void); //Just a type here typedef void(^BOLLCALLBACK)(bool succeed);//Just a type here -(void)parserobjectWithFile:(NSString *)file StartCallBack:(VOIDCALLBACK) startCallBack completionBlock:(BOLLCALLBACK) completion{ // When start dispatch_async(dispatch_get_main_queue(), ^{ startCallBack();//Make call back run in main queue }); //When finisehd set succeed to yes,otherwise set to no BOOL succeed = YES;//Pass in to...
javascript,arrays,callback,promise
Can't you achieve this by some simple refactoring? var newfunc = function(callback){ console.log(callback);//this is now a bunch of arrays in //my console log instead of a single one } var arrayNames = {key: val} var val = {k: v, k1: v, k2: v} var array = []; // move 'newfunc'...
c#,callback,garbage-collection
You can't get notification directly in manged code because managed code is suspended (or at least not guaranteed to run your thread in case of background GC) during GC. Options: You can get approximate notification with GC.RegisterForFullGCNotification as shown in Garbage Collection Notifications article. You can watch performance counters related...
In merge, you: Create a new, blank array for the return value. Consider what you want to do if array1 and array2 aren't the same length, although they are in the example usage. Use an index variable to loop from 0 through < array1.length (most likely a for loop). Fill...
javascript,google-chrome-extension,callback,oauth-2.0,identity
You are misunderstanding the identity API. You cannot use it with a custom callback URL. The API expects you to use a URL of the form https://<app-id>.chromiumapp.org/* which you can obtain with a call to chrome.identity.getRedirectURL(path) When the provider redirects to a URL matching the pattern https://<app-id>.chromiumapp.org/*, the window will...
python-3.x,callback,mouse,opencv3.0,drawrectangle
You perform drawing (displaying of an image by using cv2.imshow) only once because cv2.waitKey(0) waits indefinitely. If you use some non-zero argument it will wait for that number of milliseconds. But notice that you're constantly rewriting/modifying an image. This is probably not what you want. I think you need to...
A quick review and update of the items in the original question... Although the method shown in my question follows the Twilio documentation, the results are unrealiable. In my testing, the Twilio server only provided the required links 60% of the time. Note that all of the images tested were...
As a native recursion alternative, here's a way to do it var marker = [[43.000,-79.321],[44.000,-79],[45.000,-78],[46.000,-77]]; var result = []; var i=0, j=0; function test(){ if(j >= marker.length){ j=0; i++; } // j is done one lap, reset to 0, i++ for next lap if(i >= marker.length){ return false; } //...
android,design-patterns,android-fragments,android-activity,callback
If your app becomes more complex using the callback pattern will get messy, especially if fragments need to communicate with fragments. I'd only use that pattern for apps with low complexity (activity, one or two fragments). Clicks, events etc. should be handled inside a fragment if whatever happens stays...
javascript,asynchronous,callback,angular-file-upload
I never used async-waterfall, but if I had to do this I would use $q promises and when the resolve event is received, then you can call your desired function. Start here. Also, lookup for $q.all() - that's what will help you. Here's a $q.all() example with success event (when...
android,android-fragments,interface,callback,android-dialogfragment
you have to call setTargetFragment setTargetFragment(this, 0); in order to get a reference FragmentXYXY, in your DialogFragment. @Override public void onClick(View v) { switch (v.getId()) { case R.id.et_i: DialogFragment newFragment = FragmentAlertDialog.newInstance(MainActivity.DIALOG_I, R.string.i_select, R.array.i_array); newFragment.setTargetFragment(this, 0); newFragment.show(getFragmentManager(), "dialog"); } } ...
javascript,arrays,callback,pusher
The structure of the data variable depends on the event data you are sending through Pusher. You can use the Pusher Debug Console to test this out. The example in the image below will work and show hello in an alert for the code you have in your question. ...
When using then.call(this, function(){}); you're calling the then function as this, but that will not affect the this value of the actual callback function that you are passing. If you want to bind this to the callback, you can use bind: $http.post(url, data).then(function(){ this.saved = true; }.bind(this)); ...
As described in the docs you can use $httpBackend to make a mock for $http. You can test both ways of implementing the service (callback or promise). But I also think that promises are better to test and should be preferred. Just include ngMock in your dependencies and then you...
oauth,callback,github-api,electron
So what I was missing was the right event. The correct approach is: // Build the OAuth consent page URL var authWindow = new BrowserWindow({ width: 800, height: 600, show: false, 'node-integration': false }); var githubUrl = 'https://github.com/login/oauth/authorize?'; var authUrl = githubUrl + 'client_id=' + options.client_id + '&scope=' + options.scopes;...
Alright as @knitti suggested the script run in a completely different process, so I solved this problem by a combination of signals, files and global variables. Not claiming this to be the most elegant solution but it worked for me - import subprocess, textwrap, os, signal caller_object = None def...
Some fixes that you need to do to achieve this would be use the then instead of success function on $http. And in the then success callback you can do a return $q.reject(errorData) to reject the promise down the chain. return $http.get('url').then(function(results){ if(condition) { return $q.reject(errorData); } return result.data; //then...
jquery,ajax,backbone.js,callback
what you have shown not necessarily mean Backbone call is earlier than ajax success callback. it is probably ajax success is called first. then immediately the backbone callback is also invoked. then it depends on which one is faster, the faster one will log first. it means backbone callback is...
authentication,callback,instagram
I'm glad it was a bug. Everything is normal now.
Yes, using the $q promise library, you can achieve that. If you are using angular, $q is already in your project, just include it in the service/controller you are using. $q.all does exactly what you are looking for. Example of how it would look: var promises = []; // loop...
javascript,jquery,callback,setinterval,fade
Here is the doc for .fadeOut() There is an optional argument complete: A function to call once the animation is complete. Put the next animation in there, they too take a complete (callback) function. $("#id").fadeOut(fadeTime, function() { // code to execute after animation complete }); ...
angularjs,callback,controller,promise,angular-promise
My best practice with regards to services requesting data and returning promises is: return a promise (in DataService, return deferred.promise) in the controller, call DataService.getData(3).then(, ) So I would not pass a callback to a service function that uses a promise. The more difficult question is what should the service...
OK, after careful deugging problem identified. As Joseph mentioned, not related to fs.writeFile() at all. In my application there are in fact two file writes running "concurrently". The one listed in my question and another one, writing data progressively as it calculates some averages. The other, progressively writing function, had...
ruby-on-rails,activerecord,callback
It'll work without any issue, as Active Record wraps-up these callback methods in a single transaction. Since the object is destroyed in first yield, it seems the later is not feasible (assuming everything is running in one thread). How Rails handles this? No, object isn't destroyed in first yield. Object...
You will need to not call the callback immediately, but instead make a function that calls callback later with the expected arguments: function myFunc1(x, y) { /*do stuff*/ myFunc2(z, function(results) { callback(x, y, results); }); } The .bind() variant proposed by @thefourtheye is basically1 a shortcut for this function expression....
It is just a "short circuit" coding style. It is checking to ensure that callback isn't undefined. If it is undefined, then it is assigning it an anonymous function in order for the callback() code to not fail. It is equivalent to if(typeof(callback) == "undefined") callback = function(){}; A pitfall...
Probably, I found the error in your Utente class. You have exported your object at 2 places in your ode, which results in java.rmi.server.ExportException:object already exported. In your Utente's main() method, you have stubExport = (GraphicInterface)UnicastRemoteObject.exportObject(user,3900); where user is an object of class Utente. Also, in the same class' login()...
node.js,facebook,express,callback
If you just want to log the successful login then put this in your app.js for the route to home: router.get('/home', isAuthenticated, function(req, res, next) { console.log('GET /home login success for [%s]', req.user.username); res.render('home'); }); If you also want to greet the person on your home page by username... Somewhere...
c++,c++11,callback,synchronization,raii
Your concerns about synchronisation are a little misplaced. To summarise your problem, you have some library with which you can register a callback function and (via the void* pointer, or similar) some resources upon which the function acts via a register() function. This same library also provides an unregister() function....
There is no "best practice". However, you will find promises much easier to work with.
java,android,twitter,callback,twitter4j
I couldnt quite figure out how the intents-in-manifest business worked. Instead I did the following (and it works) Created a WebViewClient and overrided its shouldOverrideUrlLoading Set this WebViewClient to the webview and load the twitter login from there. In my WebView client I am parsing the twitter response looking for...
With arguments (err, rows), all four functions appear to be written as nodebacks and we can make a shrewd guess as to what the original working code looked like. Without modification, nodebacks can only be used as nodebacks. Inserting them raw into a promise chain won't work. But your functions...
javascript,jquery,callback,marionette,deferred
We're going to use Marionette's built in Marionette.Babysitter and ES6 Promises to solve your problem. If you read the docs carefully (or thumb through the source) you'll learn that Marionette renders child views in collection order. By default the CollectionView will maintain the order of its collection in the DOM....
As your exported function from your module is asynchronous, you need from your app to handle its result via a callback In your app: Myobject(value1, function(err, results){ //results== '{"json":"string"}' }); In your module: module.exports = function(get_this, cbk) { var request = require('request'); var options = { url: get_this, }; request(options,...
javascript,jsf,callback,commandbutton
Probably, jsf creates a new id for the button so document.getElementById('editButton') does not work. In order to solve this you may add an arbitrary style class to button like; styleClass="button myButtonToClick" and javascript should be like this; var x =document.getElementsByClassName("myButtonToClick"); x[0].click(); ...
javascript,asynchronous,error-handling,callback,npm
What they're trying to say is that you should design your modules so the asynchronous functions don't throw errors to catch, but are rather handled inside of a callback (like in the fs.readdir example you provided)... So, for instance this is what they're saying you should design your module like:...
I'm not shure whether the following works: hObject.UserData = player; I would (as you have already found out) use a global variable. I didn't test this solution, but it should work and shows how to use global variables in combination with a GUI correct. Please correct me if you found...
Finally me and Joe Cheng (whom I want to thank very much) implemented following solution. https://groups.google.com/forum/#!topic/shiny-discuss/hW4uw51r1Ak f <- function () sample(seq(1:10), 25, replace=TRUE) in1 <- cbind (f(), f(), f(), f(), f(), f()) label <- data.frame(L1= c(rep("A", 5), rep("B", 5), rep("C", 5), rep("D", 5), rep("E", 5)), L2=(sample(c("M", "FFF"), 25, replace=TRUE)), ID=seq(1,25))...
javascript,node.js,callback,filesystems
The callback is required when you need to know if/when the call succeeded. If you don't care when it's done or don't care to see if there is an error, then you don't have to pass the callback. Remember, this type of function is asynchronous. It completes some unknown time...
c++,events,callback,message,maya
You can use MEventMessage to setup a callback every time frame/current time changes. Code speaks louder than words, so here's some code with comments interspersed to illustrate how to set this up: (TLDR for the impatient first, full code excerpt will follow in the next section) TLDR: A code summary...
c#,multithreading,callback,network-programming,mutex
Considering this - I want to do this to potentially allow my main thread to continue while the writes queue up and occur. First and foremost, I want to know if there IS a way this can be done? I don't think you need a mutex for that. Are you...
javascript,asynchronous,callback
JavaScript is run with a single thread, so your while loop will use up a lot of CPU and basically freeze all other computations. Promises are one approach you can use (as mentioned in a comment). You can also pass in an object with a callback to your function. In...
javascript,callback,promise,mocha
You're overthinking it - mocha supports promises, you can return a promise and if it is fulfilled the test will pass (and if the expects throw it will fail): var collectionChecker = function(results) { expect(Array.isArray(results), 'Did not return collection'); expect(results.length === numAttr, 'Returned wrong number of models'); }; // just...
java,c#,c++,callback,delegates
C++ had "official" (non-Boost) "full" delegates from C++11 (std::function)... Before that, getting a pointer to a member function was always a little hackish... So I wouldn't consider C++ to be a good comparison :-) And C++ can overload the round parenthesis, so it is more easy to "hide" the hacks...
You have to declare a delegate type that matches the native function pointer. It probably should look like this: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int fct_line_callback(double power, IntPtr userdata); Now you can write the pinvoke declaration: [DllImport("foo.dll", CallingConvention = CallingConvention.Cdecl)] extern static int set_line(int width, fct_line_callback callback); If the callback can only be...
The server should create the token for the client. The client should pass it on all subsequent calls. Server should authenticate using it. A GUID would be hard to spoof. You can't prevent clients from doing so, but it will be difficult given a sufficiently complex identifier. You can also...
.net,callback,delegates,c++-cli
First of all if you expose Callbackfor1 and Callbackfor2 (I assume your class members are all public) then you don't also need RegisterCallback1 and RegisterCallback2: they're just helper methods that make caller code even more prolix: manager->RegisterCallback1(YourMethod); Instead of: manager->Callbackfor1 += YourMethod; However note that having your delegates public you're...
When you make an AJAX request, the call to $.ajax() returns immediately. It does not wait around for the content to come back over the network. In your example, the console.log() statements are being called before the callbacks have been completed. What you want is a single callback that gets...
swift,callback,navigation,navigationcontroller
Finally, I've found the reason for such weird behavior: The callback is running on a thread which is separate from the UI thread. In order to allow a fragment of code to do UI-related things you have to use dispatch_async() method. Here is my updated code with working navigation using...
If the loadData()s are async operations, you can do two things: Using $.ajaxComplete(): var functionA = function(callback) { loadData(fromURL1); // takes some time loadData(fromURL2); // takes some time $.ajaxComplete(function () { callback(); // Should be called AFTER the loadData() functions are finished }); } Or chaining the functions: var functionA...