Search Results

Search found 2328 results on 94 pages for 'callback'.

Page 7/94 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • POSIX AIO Library and Callback Handlers

    - by Charles Salvia
    According to the documentation on aio_read/write, there are basically 2 ways that the AIO library can inform your application that an async file I/O operation has completed. Either 1) you can use a signal, 2) you can use a callback function I think that callback functions are vastly preferable to signals, and would probably be much easier to integrate into higher-level multi-threaded libraries. Unfortunately, the documentation for this functionality is a mess to say the least. Some sources, such as the man page for the sigevent struct, indicate that you need to set the sigev_notify data member in the sigevent struct to SIGEV_CALLBACK and then provide a function handler. Presumably, the handler is invoked in the same thread. Other documentation indicates you need to set sigev_notify to SIGEV_THREAD, which will invoke the callback handler in a newly created thread. In any case, on my Linux system (Ubuntu with a 2.6.28 kernel) SIGEV_CALLBACK doesn't seem to be defined anywhere, but SIGEV_THREAD works as advertised. Unfortunately, creating a new thread to invoke the callback handler seems really inefficient, especially if you need to invoke many handlers. It would be better to use an existing pool of threads, similar to the way most network I/O event demultiplexers work. Some versions of UNIX, such as QNX, include a SIGEV_SIGNAL_THREAD flag, which allows you to invoke handlers using a specified existing thread, but this doesn't seem to be available on Linux, nor does it seem to even be a part of the POSIX standard. So, is it possible to use the POSIX AIO library in a way that invokes user handlers in a pre-allocated background thread/threadpool, rather than creating/destroying a new thread everytime a handler is invoked?

    Read the article

  • Noob boost::bind member function callback question

    - by shaz
    #include <boost/bind.hpp> #include <iostream> using namespace std; using boost::bind; class A { public: void print(string &s) { cout << s.c_str() << endl; } }; typedef void (*callback)(); class B { public: void set_callback(callback cb) { m_cb = cb; } void do_callback() { m_cb(); } private: callback m_cb; }; void main() { A a; B b; string s("message"); b.set_callback(bind(A::print, &a, s)); b.do_callback(); } So what I'm trying to do is to have the print method of A stream "message" to cout when b's callback is activated. I'm getting an unexpected number of arguments error from msvc10. I'm sure this is super noob basic and I'm sorry in advance.

    Read the article

  • jquery callback functions failing to finish execution

    - by calumbrodie
    I'm testing a jquery app i've written and have come across some unexpected behaviour $('button.clickme').live('click',function(){ //do x (takes 2 seconds) //do y (takes 4 seconds) //do z (takes 0.5 seconds) }) The event can be triggered by a number of buttons. What I'm finding is that when I click each button slowly (allowing 10 seconds between clicks) - my callback function executes correctly (actions x, y & z complete). However If I rapidly click buttons on my page it appears that the function sometimes only completes up to step x or y before terminating. My question: Is it the case that if this function is fired by a clicking second DOM element, while the first callback function is completing - will jQuery terminate the first callback and start over again? Do I have to write my callback function explicitly outside the event handler and then call it?? function doStuff() { //do x //do y //do z ( } $('button.clickme).live('click',doStuff()) If this is the case can someone explain why this is happening or give me a link to some advice on best practice on closures etc - I'd like to know the BEST way to write jQuery to improve performance etc. Thanks

    Read the article

  • JSONP callback method is not defined

    - by Micah
    I'm trying to get a jsonp callback working using jquery within a greasemonkey script. Here's my jquery: $.ajax({ url: "http://mydomain.com/MyWebService?callback=?", data: { authkey: "temphash" }, type: "get", dataType: "json", cache: false, success: function(data) { console.log(data); } }); in my webservice (asp.net) I'm returning the response with a content type of application/javascript. The response the server is actually sending back is: jsonp1276109314602({"message":"I'm getting tired of this not working"}) The jsonp1276109314602 method name is being randomly generated by jquery, and I'm grabbing it with Request.QueryString["callback"] However my success function is never called and the firebug console gives me an error saying jsonp1276109314602 is not defined. What am I doing wrong?

    Read the article

  • jQuery Star Rating plugin - select in callback causes infinite loop

    - by Ian
    Using the jQuery Star Rating plugin everything works well until I select a star rating from the rating's callback handler. Simple example: $('.rating').rating({ ... callback: function(value){ $.ajax({ type: "POST", url: ... data: {rating: value}, success: function(data){ $('.rating').rating('select', 1); } }); } }); I'm guessing this infinite loop occurs because the callback is fired after a manual 'select' as well. Once a user submits their rating I'd like to 'select' the average rating across all users (this value is in data returned to the success handler). How can I do this without triggering an infinite loop?

    Read the article

  • "Invalid Postback or callback argument" on modifying the DropDownList on the client side

    - by gnomixa
    I know why it's happening and i turned the validation on the page level, but is there a way to turn it off on the control level? "Invalid Postback or callback argument . Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %in a page. For security purposes, this feature verifies that arguments to Postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the Postback or callback data for validation."

    Read the article

  • Asynchronous Silverlight WCF callback

    - by Matt
    I've created my own WCF service and I've successfully been able to talk to it via my Silverlight client. I ran into an interesting problem on my asynchronous callbacks though. When my callback is invoked, I can't update any UI controls with the dreaded invalid cross thread access Here's what my callback function looks like private void GetTimeCallBack( object sender, Talk.ClientBase<IService>.ClientEventArgs e ) { lblDisplay.Text = e.Object.ToString(); } A quick google search showed me that I have to do this instead. private void GetTimeCallBack( object sender, Talk.ClientBase<IService>.ClientEventArgs e ) { Dispatcher.BeginInvoke( () => lblDisplay.Text = e.Object.ToString() ); } Now everything works fine, but I wasn't expecting my callback to be running on a different thread. Will I always have to use the Dispatcher class in order to modify anything within my class or is this just limited to UI elements? I've not familiar with the Dispatcher class at all so I'm looking to understand it more.

    Read the article

  • JavaScript replace with callback - performance question

    - by Tomalak
    In JavaScript, you can define a callback handler in regex string replace operations: str.replace(/str[123]|etc/, replaceCallback); Imagine you have a lookup object of strings and replacements. var lookup = {"str1": "repl1", "str2": "repl2", "str3": "repl3", "etc": "etc" }; and this callback function: var replaceCallback = function(match) { if (lookup[match]) return lookup[match]; else return match; } How would you assess the performance of the above callback? Are there solid ways to improve it? Would if (match in lookup) //.... or even return lookup[match] | match; lead to opportunities for the JS compiler to optimize, or is it all the same thing?

    Read the article

  • How to access the jQuery event object in a Seaside callback

    - by Mef
    Basically, I want to translate the following into Seaside Smalltalk: $(".myDiv").bind('click', function(e) { console.log(e); }); Besides that I don't want to console.log the event, but access it in my ajax callback. The most promising approach seemed to be something like html div onClick: (html jQuery ajax callback: [:v | self halt] value: (???); with: 'Foo'. But I couldn't find any way to access the event that caused the callback. Intuitively, I would try html jQuery this event for the ??? part, but the Seaside jQuery wrapper doesn't know any message that comes close to event. Any help is appreciated. There has to be away to access the event data...

    Read the article

  • Passing variables to callback functions

    - by mickyjtwin
    I am trying to write a jQuery plugin, that can be applied to a selector. Within this plugin, there are multiple calls to webservices, where callback methods are required. The problem I am having is maintaining the current context item in the each loop of the selector. (function($){ $.fn.myMethod = function(){ return this.each(function(){ var c = $(this); $.api.methodToCall("", CallbackFunction); }); }; function CallbackFunction(data, result){ // do stuff based on c } })(jQuery); Normally, you would provide the callback function straight away, which allows me to access c, however within the callback function, there potentially is another api call, so it would start to get messy. Is there any way to do this?

    Read the article

  • How to use xml response as XMLObject outside of ajax callback function

    - by Anthony
    Hopefully I've just made a dumb oversight, but I can't figure out why the following doesn't work: $(function() { var xml; $.get( "somexml.xml", function(data){ xml = data; }, "xml"); alert(xml); }); If I put the alert inside of the callback function, I get back object XMLdocument but if I place it outside of the ajax call, I get undefined. Since my goal is to have a new DOM to parse, I don't want the entire handling of the XMLdocument to be within the callback function. I've tried defining the variable outside of the entire onready function, inside at the top (like above) and inside the callback function, all with no luck. According to Specifying the Data Type for Ajax Requests in the jquery documentation, this should be possible.

    Read the article

  • What is the best way to expose a callback API - C++

    - by rursw1
    Hi, I have a C++ library that should expose some system\ resource calls as callbacks from the linked application. For example: the interfacing application (which uses this library) can send socket management callback functions - send, receive, open, close etc., and the library will use this implementation in stead of the library's implementation. (This way enables the application to manage the sockets by itself, can be useful). This library has to expose also more callbacks, like, for example, a password validation, so I wonder if there is a preferred method to expose the callback sending option in one API. Something like: int AddCallbackFunc (int functionCallbackType, <generic function prototype>, <generic way to pass some additional arguments>) Then within my library I will assign the callback to the appropriate function pointer according to the functionCallbackType parameter. Is there any way to implement it in a generic way which will fit ANY function prototype and ANY additional arguments? Your help will be more than appreciated... Thanks!

    Read the article

  • Callback exception/error handling for ASP TreeView OnTreeNodePopulate?

    - by MHutchinson
    We're using an asp:TreeView configured with lazy loading. The callback method assigned for OnTreeNodePopulate throws an exception if the user has been logged out since the page was loaded. What we want to do is to direct the user to the login page. First attempt was to catch the exception on the server and try Response.Redirect(...), but that doesn't work because you can't redirect within a callback. I've tried various other approaches, including using ClientScript.RegisterStartupScript(...) but that doesn't seem to work for OnTreeNodePopulate. If there was some way we could hook into the callback event handling on the client side then it would be easy, but the TreeView doesn't seem to offer anything here. Suggestions?

    Read the article

  • ASP.NET Client to Server communication

    - by Nelson
    Can you help me make sense of all the different ways to communicate from browser to client in ASP.NET? I have made this a community wiki so feel free to edit my post to improve it. Specifically, I'm trying to understand in which scenario to use each one by listing how each works. I'm a little fuzzy on UpdatePanel vs CallBack (with ViewState): I know UpdatePanel always returns HTML while CallBack can return JSON. Any other major differences? ...and CallBack (without ViewState) vs WebMethod. CallBack goes through most of the Page lifecycle, WebMethod doesn't. Any other major differences? IHttpHandler Custom handler for anything (page, image, etc.) Only does what you tell it to do (light server processing) Page is an implementation of IHttpHandler If you don't need what Page provides, create a custom IHttpHandler If you are using Page but overriding Render() and not generating HTML, you probably can do it with a custom IHttpHandler (e.g. writing binary data such as images) By default can use the .axd or .ashx file extensions -- both are functionally similar .ashx doesn't have any built-in endpoints, so it's preferred by convention Regular PostBack (System.Web.UI.Page : IHttpHandler) Inherits Page Full PostBack, including ViewState and HTML control values (heavy traffic) Full Page lifecycle (heavy server processing) No JavaScript required Webpage flickers/scrolls since everything is reloaded in browser Returns full page HTML (heavy traffic) UpdatePanel (Control) Control inside Page Full PostBack, including ViewState and HTML control values (heavy traffic) Full Page lifecycle (heavy server processing) Controls outside the UpdatePanel do Render(NullTextWriter) Must use ScriptManager If no client-side JavaScript, it can fall back to regular PostBack with no JavaScript (?) No flicker/scroll since it's an async call, unless it falls back to regular postback. Can be used with master pages and user controls Has built-in support for progress bar Returns HTML for controls inside UpdatePanel (medium traffic) Client CallBack (Page, System.Web.UI.ICallbackEventHandler) Inherits Page Most of Page lifecycle (heavy server processing) Takes only data you specify (light traffic) and optionally ViewState (?) (medium traffic) Client must support JavaScript and use ScriptManager No flicker/scroll since it's an async call Can be used with master pages and user controls Returns only data you specify in format you specify (e.g. JSON, XML...) (?) (light traffic) WebMethod Class implements System.Web.Service.WebService HttpContext available through this.Context Takes only data you specify (light traffic) Server only runs the called method (light server processing) Client must support JavaScript No flicker/scroll since it's an async call Can be used with master pages and user controls Returns only data you specify, typically JSON (light traffic) Can create instance of server control to render HTML and sent back as string, but events, paging in GridView, etc. won't work PageMethods Essentially a WebMethod contained in the Page class, so most of WebMethod's bullet's apply Method must be public static, therefore no Page instance accessible HttpContext available through HttpContext.Current Accessed directly by URL Page.aspx/MethodName (e.g. with XMLHttpRequest directly or with library such as jQuery) Setting ScriptManager property EnablePageMethods="True" generates a JavaScript proxy for each WebMethod Cannot be used directly in user controls with master pages and user controls Any others?

    Read the article

  • C# wrapper and Callbacks

    - by fergs
    I'm in the process of writing a C# wrapper for Dallmeier Common API light (Camera & Surviellance systems) and I've never written a wrapper before, but I have used the Canon EDSDK C# wrapper. So I'm using the Canon wrapper as a guide to writing the Dallmeier wrapper. I'm currently having issues with wrapping a callback. In the API manual it has the following: dlm_connect int(unsigned long uLWindowHandle, const char * strIP, const char* strUser1, const char* strPwd1, const char* strUser2, const char* strPwd2, void (*callback)(void *pParameters, void *pResult, void *pInput), void * pInput) Arguments - ulWindowhandle - handle of the window that is passed to the ViewerSDK to display video and messages there - strUser1/2 - names of the users to log in. If only single user login is used strUser2 is - NULL - strPwd1/2 - passwords of both users. If strUser2 is NULL strPwd2 is ignored. Return This function creates a SessionHandle that has to be passed Callback pParameters will be structured: - unsigned long ulFunctionID - unsigned long ulSocketHandle, //handle to socket of the established connection - unsigned long ulWindowHandle, - int SessionHandle, //session handle of the session created - const char * strIP, - const char* strUser1, - const char* strPwd1, - const char* strUser2, - const char * strPWD2 pResult is a pointer to an integer, representing the result of the operation. Zero on success. Negative values are error codes. So from what I've read on the Net and Stack Overflow - C# uses delegates for the purpose of callbacks. So I create a my Callback function : public delegate uint DallmeierCallback(DallPparameters pParameters, IntPtr pResult, IntPtr pInput); I create the connection function [DllImport("davidapidis.dll")] public extern static int dlm_connect(ulong ulWindowHandle, string strIP, string strUser1, string strPwd1, string strUser2, string strPwd2, DallmeierCallback inDallmeierFunc And (I think) the DallPParameters as a struct : [StructLayout(LayoutKind.Sequential)] public struct DallPParameters { public ulong ulfunctionID; public ulong ulsocketHandle; public ulong ulWindowHandle; ... } All of this is in my wrapper class. Am I heading in the right direction or is this completely wrong?

    Read the article

  • WCF Callbacks often break

    - by cdecker
    I'm having quite some trouble with the WCF Callback mechanism. They sometimes work but most of the time they don't. I have a really simple Interface for the callbacks to implement: public interface IClientCallback { [OperationContract] void Log(string content); } I then implmenent that interface with a class on the client: [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] [ServiceContract] internal sealed class ClientCallback : IClientCallback { public void Log(String content){ Console.Write(content); } } And on the client I finally connect to the server: NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.Transport); EndpointAddress endpoint = new EndpointAddress("net.tcp://127.0.0.1:1337"); ClientCallback callback= new ClientCallback(); DuplexChannelFactory<IServer> factory = new DuplexChannelFactory<IServer>(callback,tcpbinding, endpoint); factory.Open(); _connection = factory.CreateChannel(); ((ICommunicationObject)_connection).Faulted += new EventHandler(RecreateChannel); try { ((ICommunicationObject)_connection).Open(); } catch (CommunicationException ce) { Console.Write(ce.ToString()); } To invoke the callback I use the following: OperationContext.Current.GetCallbackChannel().Log("Hello World!"); But it just hangs there, and after a while the client complains about timeouts. Is there a simple solution as to why?

    Read the article

  • WCF service and COM interop callback

    - by Sjblack
    I have a COM object that creates an instance of a WCF service and passes a handle to itself as a callback. The com object is marked/initialized as MTA. The problem being every instance of the WCF service that makes a call to the callback occurs on the same thread so they are being processed one at a time which is causing session timeouts under a heavy load. The WCF service is session based not sure if that makes any difference.

    Read the article

  • Updating a gridview based on dundas chart callback

    - by Daud
    I have a dundas pie chart which when clicked issues a client callback which updates another chart associated with it. Basically its like a drill down thing. I also want to update my gridview based on the user's selection of the pie. But since the update of chart is being done using dundas client callback I'm unable to rebind my Gridview. Is there any way to do it? .

    Read the article

  • node.js callback getting unexpected value for variable

    - by defrex
    I have a for loop, and inside it a variable is assigned with var. Also inside the loop a method is called which requires a callback. Inside the callback function I'm using the variable from the loop. I would expect that it's value, inside the callback function, would be the same as it was outside the callback during that iteration of the loop. However, it always seems to be the value from the last iteration of the loop. Am I misunderstanding scope in JavaScript, or is there something else wrong? The program in question here is a node.js app that will monitor a working directory for changes and restart the server when it finds one. I'll include all of the code for the curious, but the important bit is the parse_file_list function. var posix = require('posix'); var sys = require('sys'); var server; var child_js_file = process.ARGV[2]; var current_dir = __filename.split('/'); current_dir = current_dir.slice(0, current_dir.length-1).join('/'); var start_server = function(){ server = process.createChildProcess('node', [child_js_file]); server.addListener("output", function(data){sys.puts(data);}); }; var restart_server = function(){ sys.puts('change discovered, restarting server'); server.close(); start_server(); }; var parse_file_list = function(dir, files){ for (var i=0;i<files.length;i++){ var file = dir+'/'+files[i]; sys.puts('file assigned: '+file); posix.stat(file).addCallback(function(stats){ sys.puts('stats returned: '+file); if (stats.isDirectory()) posix.readdir(file).addCallback(function(files){ parse_file_list(file, files); }); else if (stats.isFile()) process.watchFile(file, restart_server); }); } }; posix.readdir(current_dir).addCallback(function(files){ parse_file_list(current_dir, files); }); start_server(); The output from this is: file assigned: /home/defrex/code/node/ejs.js file assigned: /home/defrex/code/node/templates file assigned: /home/defrex/code/node/web file assigned: /home/defrex/code/node/server.js file assigned: /home/defrex/code/node/settings.js file assigned: /home/defrex/code/node/apps file assigned: /home/defrex/code/node/dev_server.js file assigned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js stats returned: /home/defrex/code/node/main_urls.js For those from the future: node.devserver.js

    Read the article

  • Javascript callback function does not work in IE8!

    - by Abhishek
    I have a callback function in my open social application which fetches remote date. This works perfect on Crome and Mozila browers but not in IE8. Following is the example for the same, help will be appriciated: This funcation: gadgets.io.makeRequest(url, response, params) makes the callback call and following function process the responce: function response(obj) { var str = obj.text; var offerDtlPg = str.substr(0, str.length); document.getElementById('pplOfrDetls').innerHTML = offerDtlPg; };

    Read the article

  • callback in android?

    - by androidbase Praveen
    in android application development, i frequently go through the word "CALLBACK" in many places. i want to know want it means to tell us technically. and how i can manage the callback of the applications. i would need a guidance to understand about it....

    Read the article

  • Form validation with optional File Upload field callback

    - by MotiveKyle
    I have a form with some input fields and a file upload field in the same form. I am trying to include a callback into the form validation to check for file upload errors. Here is the controller for adding and the callback: public function add() { if ($this->ion_auth->logged_in()): //validate form input $this->form_validation->set_rules('title', 'title', 'trim|required|max_length[66]|min_length[2]'); // link url $this->form_validation->set_rules('link', 'link', 'trim|required|max_length[255]|min_length[2]'); // optional content $this->form_validation->set_rules('content', 'content', 'trim|min_length[2]'); $this->form_validation->set_rules('userfile', 'image', 'callback_validate_upload'); $this->form_validation->set_error_delimiters('<small class="error">', '</small>'); // if form was submitted, process form if ($this->form_validation->run()) { // add pin $pin_id = $this->pin_model->create(); $slug = strtolower(url_title($this->input->post('title'), TRUE)); // path to pin folder $file_path = './uploads/' . $pin_id . '/'; // if folder doesn't exist, create it if (!is_dir($file_path)) { mkdir($file_path); } // file upload config variables $config['upload_path'] = $file_path; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '2048'; $config['max_width'] = '1920'; $config['max_height'] = '1080'; $config['encrypt_name'] = TRUE; $this->load->library('upload', $config); // upload image file if ($this->upload->do_upload()) { $this->load->model('file_model'); $image_id = $this->file_model->insert_image_to_db($pin_id); $this->file_model->add_image_id_to_pin($pin_id, $image_id); } } // build page else: // User not logged in redirect("login", 'refresh'); endif; } The callback: function validate_upload() { if ($_FILES AND $_FILES['userfile']['name']): if ($this->upload->do_upload()): return true; else: $this->form_validation->set_message('validate_upload', $this->upload->display_errors()); return false; endif; else: return true; endif; } I am getting the error Fatal error: Call to a member function do_upload() on a non-object on line 92 when I try to run this. Line 92 is the if ($this->upload->do_upload()): line in the validate_upload callback. Am I going about this the right way? What's triggering this error?

    Read the article

  • How to initiate JavaScript Callback with MVC2 using RenderAction

    - by Zacho
    I am building a dashboard where I am iterating through a list of controls to render, and I need to initiate a general callback both after each control and after they are all completed. I was curious what the best way to handle this is. I can get the control specific callback fired off by placing myUserControlCallback(); in the user control itself. I'm just not sure how to run something like allControlsRendered();. Any ideas?

    Read the article

  • PHP Curl progress bar (callback returning percentage)

    - by WarDoGG
    I have implemented the curl progress bar using curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, 'callback'); curl_setopt($curl, CURLOPT_BUFFERSIZE,64000); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); and a callback function. problem is, the script is outputting the percentage on my html everytime like this : 0 0.1 0.2 0.2 0.3 0.4 .. .. .. 1 1.1 How do i combine this with CSS to show a changing progress bar ?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >