callback

jQuery ajax method using a callback to update an elements class

Hi, I want to fire a function when an image is clicked, and that function will hit a URL passing it a parameter and then update the containing div's class with the value I get back from the URL. Can someone help me with code for this? My DOM looks like: <div class="c1"><img src="/images/hello.jpg"/></div> My URL is http://www.examp...

How can I use a code ref as a callback in Perl?

I have the following code in my class : sub new { my $class = shift; my %args = @_; my $self = {}; bless( $self, $class ); if ( exists $args{callback} ) { $self->{callback} = $args{callback}; } if ( exists $args{dir} ) { $self->{dir} = $args{dir}; } return $self; } sub test { my ...

Accessing the Main thread with the callback

Hi. I have a program in C# that connects to a server using a DuplexChannelFactory, and that server can call methods from client side by callback, the problem is that I have no idea how to access the Main Thread were the connection was created from the callback methods. Is there any way to do this, by means of passing an object, or do I ...

Tricky jQuery operation, not sure if I am using 'this' property either.

Using jQuery, I am binding some image tags with a click event like this: $('.imageClass > a > img').bind('click', onImageClick); this.onImageClick = function() { $.post("/blah/123", { test : 'a' }, function(data) { myCallback(this, data); }, "json"); } this.myCallback(event, data) { alert($(event).parent.attr("href")); }; My...

How do I create a class with asynchronous capabilities (similiar to SqlCommand or WebRequest)?

I've been reading a lot about asynchronous programming recently, as I need to create a multi-threaded application. Unfortunately I can't seem to bring my newly acquired knowledge together into one cohesive and useful unit! I'm hoping someone can give me some pointers on how to construct the following: I have a class that does a lot ...

How to pass and then invoke generic callback functions without causing circular dependency.

Couldn't creatively shorten the title :) I have been using a variation of the below solution, however I always wondered if there is a better/cleaner way to implement it. I am looking for non-boost solution. We can, though, look at the implementation of boost and C++0x, as it will soon be relevant. //Notice the use of template template...

calling a callback from a thread using function pointers

Hello, c program compiler gcc I have 3 files. main.c stop_watch.h and stop_watch.c This program does work. I call start_stopwatch. And it will callback in main.c timeout_cb() after the time has expired. I also run this in a seperate thread, as I don't want to block in main, as I will have other code I need to run. 1) The seconds in g...

.NET framework based windows service and COM callbacks (connection points)

Hi! I'm currently developing on application that uses legacy COM-based object. This object resides in standalone executable and have COM connection point defined on it. When I subscribe on this connection point within WinForms application everything is ok - all callbacks received smoothly. When using same code from NET framework based Wi...

How to go beyond callback programming?

I've noticed that a big part of my code is built around callbacks. Is this considered a "design flaw"? Are there better design patterns that I should follow? ...

What is a good definition of a "userdata pointer"?

I have searched for a good explanation but can't find one. I could try to write one myself but I'd prefer if someone with better english could help me explain this for Zan Lynx in the comment here. ...and it seems like there should be a good explanation somewhere, why not here? ...

How to — callback functions

Hi guys. I have a big problem writing a small piece of code using JS/jQuery (don't know which of these is causing the problem). Anyhow, here we go: $('#themePicker').unbind().click(function() { var t = $(this); modalwindow2(t, function() { console.log(1); }, function(w) { console.log(w); }); return false...

Using ActiveRecord, is there a way to get the old values of a record during after_update

Hey everyone, Setup using a simple example: I've got 1 table (Totals) that holds the sum of the 'amount' column of each record in a second table (Things). When a thing.amount gets updated, I'd like to simply add the difference between the old value and the new value to total.sum. Right now I'm subtracting self.amount during 'before_up...

How do you attach a custom callback function to the jquery autocomplete extension?

I'm using the jquery autocomplete 1.0.2 extension by Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer. I am attempting to execute my own callback function when .show() and .hide() are called from within the autocomplete control. I haven't found any way for it to actually recognize my callback function. If anyone is famil...

pthread callbacks interupt user input

I have written my own stop_watch module. That will create a thread and go to sleep for a period of seconds. Once the seconds have expired it will call a callback function in the main.c and inform the user the time has expired. This is so that the user will only have 3 seconds to enter a digit and they will have to enter 5 digits. If th...

I need to create a simple callback in c++? Should I use boost::function?

Suppose I have some code like this: class Visitor { public: Visitor(callBackFunction) {} void visit() { //do something useful invokeCallback(); } } class ClassThatCanBeVisited { Visitor &visitor; public: ClassThatCanBeVisited(Visitor &_visitor) : visitor(_visitor){} void s...

Does this fit your definition of a Callback?

Definition of Callback: A Function that is set as a property within a Component. And is usually called when some event occurs on the Component. For Example: If you wish to display a dialog which reads "I was clicked" when the user clicks on the Component componentB, you would write a method stored as a variable which does this: var ...

How is a closure different from a callback?

I asked a question about callbacks and arrived at another question (see comment). How is a closure different from a callback? ...

W/o function pointers, what's a recommended way to implement Callback in Java - other than interfaces?

I have a couple of classes that want to pass each other some information and be called back later, using that information (Callback pattern). Within my application, this mechanism serves two purposes: scheduled / delayed execution asynchronous execution involving messaging My objects basically say to each other "when you're finished...

Store pointers to member function in the map.

I'd like to map string to an instance member functions, and store each mapping in the map. What is the clean way of doing something like that? class MyClass { //........ virtual double GetX(); virtual double GetSomethingElse(); virtual double GetT(); virtual double GetRR(); //........ }; class Processor { private:...

function pointers callbacks C

Hello, I have started to review callbacks. I found this link: http://stackoverflow.com/questions/142789/what-is-a-callback-in-c-and-how-are-they-implemented which has a good example of callback which is very similar to what we use at work. However, I have tried to get it to work, but I have many errors. #include <stdio.h> /* Is the ...