Search Results

Search found 3645 results on 146 pages for 'handler'.

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

  • C#. Saving information about events and event handlers and removing handlers using this information

    - by Philipp
    I have an object which is creating several event handlers using lambda expressions, and I need to remove all handlers created in that object in one time. I'm trying to create some unified static object which will 'know' which handler relates to which object and event if event handler was created through this static object. I tried something like code below, but I don't understand how to save events and event handlers objects, to be able remove handlers in one time. class Program { static void Main(string[] args) { var EventSender = new EventSender(); var EventReceiver = new EventReceiver(EventSender); EventSender.Invoke(" some var "); LinkSaver.RemoveEvent(EventReceiver); // ?? Console.ReadKey(); } } public class ObjLink{ public object Event; public object Action; } public static class LinkSaver { public static void SetEvent<T>(object obj, Action<T> Event, T Action) { Event(Action); var objLink = new ObjLink{Event = Event, Action = Action}; if (!Links.ContainsKey(obj)) Links.Add(obj, new List<ObjLink>{objLink}); else Links[obj].Add(objLink); } static Dictionary<object,List<ObjLink>> Links = new Dictionary<object, List<ObjLink>>(); public static void RemoveEvent(object obj){ foreach(var objLink in Links[obj]){ // objLink.Event -= objLink.Action; ??? } } } public class EventReceiver { public EventReceiver(EventSender obj) { LinkSaver.SetEvent<EventSender.TestDelegate>(this, obj.SetEvent, str => Console.WriteLine(str + " test event!")); } } public class EventSender { public void Invoke(string var) { if (eventTest != null) eventTest(var); } public void SetEvent(TestDelegate Action) { eventTest += Action; } public delegate void TestDelegate(string var); private event TestDelegate eventTest; // by the way public void RemoveFromEvent() { foreach (var handler in eventTest.GetInvocationList()) eventTest -= (TestDelegate)handler; } }

    Read the article

  • how can i disable the default console handler, while using the java logging api ?

    - by loudiyimo
    Hi I am trying to implement the java logging in my application. I want to use two handlers. A file handler and my own console handler. Both of my handlers work fine. My logging is send to a file and to the console . My logging is also sent to the default console handler, which i do not want. If you run my code you will see extra two line sent to the console. I don't want to use de default console handler. Does anyone know how to disable the default console handler. I only want to use the two hadlers i have created. Handler fh = new FileHandler("test.txt"); fh.setFormatter(formatter); logger.addHandler(fh); Handler ch = new ConsoleHandler(); ch.setFormatter(formatter); logger.addHandler(ch); import java.util.Date; import java.util.logging.ConsoleHandler; import java.util.logging.FileHandler; import java.util.logging.Formatter; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.LogRecord; import java.util.logging.Logger; public class LoggingExample { private static Logger logger = Logger.getLogger("test"); static { try { logger.setLevel(Level.INFO); Formatter formatter = new Formatter() { @Override public String format(LogRecord arg0) { StringBuilder b = new StringBuilder(); b.append(new Date()); b.append(" "); b.append(arg0.getSourceClassName()); b.append(" "); b.append(arg0.getSourceMethodName()); b.append(" "); b.append(arg0.getLevel()); b.append(" "); b.append(arg0.getMessage()); b.append(System.getProperty("line.separator")); return b.toString(); } }; Handler fh = new FileHandler("test.txt"); fh.setFormatter(formatter); logger.addHandler(fh); Handler ch = new ConsoleHandler(); ch.setFormatter(formatter); logger.addHandler(ch); LogManager lm = LogManager.getLogManager(); lm.addLogger(logger); } catch (Throwable e) { e.printStackTrace(); } } public static void main(String[] args) { logger.info("why does my test application use the standard console logger ?\n" + " I want only my console handler (Handler ch)\n " + "how can i turn the standard logger to the console off. ??"); } }

    Read the article

  • Perl - How to use a process Handle created in a Module in another Perl Script

    - by Zwik
    Ultimately, what I want to do is to start a process in a module and parse the output in real time in another script. What I want to do : Open a process Handler (IPC) Use this attribute outside of the Module How I'm trying to do it and fail : Open the process handler Save the handler in a module's attribute Use the attribute outside the module. Code example : #module.pm self->{PROCESS_HANDLER}; sub doSomething{ ... open( self->{PROCESS_HANDLER}, "run a .jar 2>&1 |" ); ... } #perlScript.pl my $module = new module(...); ... $module->doSomething(); ... while( $module->{PROCESS_HANDLER} ){ ... }

    Read the article

  • Accessing class member variables inside a BackgroundWorker's DoWork event handler, and other Backgro

    - by Justin
    Question 1 In the DoWork event handler of a BackgroundWorker, is it safe to access (for both reading and writing) member variables of the class that contains the BackgroundWorker? Is it safe to access other variables that are not declared inside the DoWork event handler itself? Obviously DoWork should not be accessing any UI objects of, say, a WinForms application, as the UI should only be updated from the UI thread. But what about accessing other (not UI-related) member variables? The reason why I ask is that I've seen the occasional comment come up while Googling saying that accessing member variables is not allowed. The only example I can find at the moment is a comment on this MSDN page, which says: Note, that the BGW can cause exceptions if it attempts to access or modify class level variables. All data must be passed to it by delegates and events. And also: NEVER. NEVER. Never try to reference variables not declared inside of DoWork. It may seem to work at times, but in reality you are just getting lucky. As far as I know, MSDN itself does not document any restrictions of this kind (although if I'm wrong, I'd appreciate a link). But comments like these do seem to pop up every now and again. (Of course if DoWork does access/modify a member variable that could be accessed/modified by the main thread at the same time, it is necessary to synchronise access to that field, eg by using a locking object. But the above quotes seem to require a blanket ban of accessing member variables, rather than just synchronising access!) Question 2 To make this into a more general question, are there any other (not documented?) restrictions that users of the BackgroundWorker should be aware of, aside from the above? Any "best practices", perhaps?

    Read the article

  • How to get HTTP status code in HTTPService fault handler

    - by Ankur
    I am calling a server method through HTTPService from client side. The server is a RestFul web service and it might respond with one of many HTTP error codes (say, 400 for one error, 404 for another and 409 for yet another). I have been trying to find out the way to determine what was the exact error code sent by the server. I have walked teh entire object tree for the FaultEvent populated in my fault handler, but no where does it tell me the error code. Is this missing functionality in Flex? My code looks like this: The HTTP Service declaration: <mx:HTTPService id="myServerCall" url="myService" method="GET" resultFormat="e4x" result="myServerCallCallBack(event)" fault="faultHandler(event)"> <mx:request> <action>myServerCall</action> <docId>{m_sDocId}</docId> </mx:request> </mx:HTTPService> My fault handler code is like so: private function faultHandler(event : FaultEvent):void { Alert.show(event.statusCode.toString() + " / " + event.fault.message.toString()); }

    Read the article

  • Interrupting Prototype handler, alert() vs event.stop()

    - by lxs
    Here's the test page I'm using. This version works fine, forwarding to #success: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head> <script type="text/javascript" src="prototype.js"></script> </head><body> <form id='form' method='POST' action='#fail'> <button id='button'>Oh my giddy aunt!</button> <script type="text/javascript"> var fn = function() { $('form').action = "#success"; $('form').submit(); } $('button').observe('mousedown', fn); </script> </form> </body></html> If I empty the handler: var fn = function() { } The form is submitted, but of course we are sent to #fail this time. With an alert in the handler: var fn = function() { alert("omg!"); } The form is not submitted. This is awfully curious. With event.stop(), which is supposed to prevent the browser taking the default action: var fn = function(event) { event.stop(); } We are sent to #fail. So alert() is more effective at preventing a submission than event.stop(). What gives? I'm using Firefox 3.6.3 and Prototype 1.6.0.3. This behaviour also appears in Prototype 1.6.1.

    Read the article

  • .net user control event handler lost on postback

    - by user154008
    I have a menu usercontrol called LeftMenu that has a bulletedlist of linkitems. It's on the ascx page as such: <asp:BulletedList ID="PublisherList" DisplayMode="LinkButton" OnClick="PublisherList_Click" cssClass="Menu" runat="server"></asp:BulletedList> I databind the list in the page_load under if(!isPostBack) I'm having an issue on a page that loads the control. When the page first loads, the event handler fires. However, when the page posts back it no longer fires and in IE8, when I'm debugging, I get "Microsoft JScript runtime error: Object expected" in Visual Studio pointing at "doPostBack('LeftMenu$PublisherList','0')." In FF I don't get the error, but nothing happens. I'm **not loading the control dynamically, it's loaded on the aspx page using: <%@ Register TagPrefix="Standards" TagName="LeftMenu" Src="LeftMenu.ascx" %> <Standards:LeftMenu ID="LeftMenu" runat="server"/> Any ideas of where I'm losing the event handler? I just realized this is happening on another user control I have as well. A text box and a button and I'm using the default button to make sure pressing the enter key uses that button. .Net converts that in the html to: <div id="SearchBarInclude_SearchBar" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'SearchBarInclude_QuickSearchButton')"> so as soon as i enter a key in the box I get a javascript error at the line saying "object expected." It seems like the two issues are related. Edit Again: I think I need to clarify. It's not that I'm clicking on the menu item and it can't find the selected item on postback. I have this search page with the left navigation on it and then the main content of the page is something that causes a postback. Everything is fine with this postback. Once that page has been posted back, now if I click on the bulleted list in the left navigation I get a javascript error and it fails. The page_init for the LeftMenu control is never called.

    Read the article

  • HTTP Handler error when downloading files - SSL

    - by Chiefy
    Ok big problem as this is affecting two projects on our new server. We have a file that is downloaded by users, the files are downloaded using a HTTPHandler. Since moving the site to the server and setting SSL the downloads have stopped working and we get an error message "Unable to download DownloadDocument.ashx" from site". DownloadDocument.ashx is the handler page that is set in the web.config and the button that goes there is a hyperlink with the id of the document as a querystring. Ive read the article on http://support.microsoft.com/kb/316431 and read a few other requests on this site but nothing seems to be working. This problem only happens in IE and works fine when I run it on the server in http instead of https. public override void HandleRequest(HttpContext context) { Guid guid = new Guid(context.Request.QueryString["ID"]); DataTable dt = Documents.GetDocument(guid); if (dt != null) { context.Response.Cache.SetCacheability(HttpCacheability.Private); context.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", dt.Rows[0]["DocumentName"].ToString())); context.Response.AddHeader("Content-Transfer-Encoding", "binary"); context.Response.AddHeader("Content-Length", ((byte[])dt.Rows[0]["Document"]).Length.ToString()); context.Response.ContentType = string.Format("application/{0}", dt.Rows[0]["Extension"].ToString().Remove(0, 1)); context.Response.Buffer = true; context.Response.BinaryWrite((byte[])dt.Rows[0]["Document"]); context.Response.Flush(); context.Response.End(); } } The above is my current code for the request. Ive used the base handler on http://haacked.com/archive/2005/03/17/AnAbstractBoilerplateHttpHandler.aspx. Any ideas on what this might be and how we can fix it. Thanks in advance for all responses.

    Read the article

  • jQuery adding a row to a table with click() handler for tr

    - by Dave
    I'm having an issue with a control I'm building that contains a table where the body is scrollable. The rows have a click() function handler established like: /** * This function is called when the user clicks the mouse on a row in * our scrolling table. */ $('.innerTable tr').click (function (e) { // // Only react to the click if the mouse was clicked in the DIV or // the TD. // if (event.target.nodeName == 'DIV' || event.target.nodeName == 'TD' ) { // // If the user wasn't holding down the control key, then deselect // any previously selected columns. // if (e.ctrlKey == false) { $('.innerTable tr').removeClass ('selected'); } // // Toggle the selected state of the row that was clicked. // $(this).toggleClass ('selected'); } }); There is a button that adds rows to the table like: $('#innerTable > tbody:last').append('<tr>...some information...</tr>'); While the rows ARE added successfully, for some reason, the static rows work with the click handler, but the newly added rows do not. Is there something I'm missing? Thanks in advance!

    Read the article

  • pthread_join from a signal handler

    - by liv2hak
    I have a capture program which in addition do capturing data and writing it into a file also prints some statistics.The function that prints the statistics static void* report(void) { /*Print statistics*/ } is called roughly every second using an ALARM that expires every second.So The program is like void capture_program() { pthread_t report_thread while(!exit_now) { if(pthread_create(&report_thread,NULL,report,NULL)){ fprintf(stderr,"Error creating reporting thread! \n"); } /* Capturing code -------------- -------------- */ if(doreport) usleep(5); } } void *report(void *param) { while(true) { if(doreport) { doreport = 0 //access some register from hardware usleep(5) } } } The expiry of the timer sets the doreport flag.If this flag is set report() is called which clears the flag.I am using usleep to alternate between two threads in the program.This seems to work fine. I also have a signal handler to handle SIGINT (i.e CTRL+C) static void anysig(int sig) { if (sig != SIGINT) dagutil_set_signal_handler(SIG_DFL); /* Tell the main loop to exit */ exit_now = 1; return; } My question: 1) Is it safe to call pthread_join from inside the signal handler? 2) Should I use exit_now flag for the report thread as well?

    Read the article

  • Clear/Remove JavaScript Event Handler

    - by Jordan Terrell
    Greetings all - Given the following HTML fragment: <form id="aspnetForm" onsubmit="alert('On Submit Run!'); return true;"> I need to remove/clear the handler for the onsubmit event and register my own using jQuery or any other flavor of JavaScript usage. Anyone know how to do this? Thanks - Jordan

    Read the article

  • Paypal IPN Handler for Cart

    - by kimmothy16
    Hey everyone! I'm using a Paypal add to cart button for a simple ecommerce website. I had a Paypal IPN handler written in PHP that was successfully working for 'Buy it Now' buttons and purchasing one item at a time. I would run a database query each time to update the store's inventory to reflect the purchase. Now I'm upgrading this store to a 'cart' version so people could check out with multiple items at a time. Would anyone be able to tell me, in general, how my IPN handler would need to be altered to accommodate this? I'm unsure of what a response from Paypal looks like for a cart purchase as opposed to a buy it now purchase. Thanks, any help or examples of working IPN cart scripts would be very appreciated! My current code is below.. // Paypal POSTs HTML FORM variables to this page // we must post all the variables back to paypal exactly unchanged and add an extra parameter cmd with value _notify-validate // initialise a variable with the requried cmd parameter $req = 'cmd=_notify-validate'; // go through each of the POSTed vars and add them to the variable foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; // In a live application send it back to www.paypal.com // but during development you will want to uswe the paypal sandbox // comment out one of the following lines $fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30); //$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // or use port 443 for an SSL connection //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $item_name = stripslashes($_POST['item_name']); $item_number = $_POST['item_number']; $item_id = $_POST['custom']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; //full amount of payment. payment_gross in US $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; //unique transaction id $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $size = $_POST['option_selection1']; $item_id = $_POST['item_id']; $business = $_POST['business']; if ($payment_status == 'Completed') { // UPDATE THE DATABASE }

    Read the article

  • Cruisecontrol.NET & IIS7 Static File Handler Problem

    - by Mr. Flibble
    I'm trying to get Cruisecontrol.NET running with Server 2008/IIS7 and when I try and navigate to the dashboard I get the following error: HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler. I'm a bit lost in IIS7 so it could be something pretty straightforward. They (cc.net) do some funny stuff with http handlers in the web.config which may be related to the problem: Anyone have any pointers?

    Read the article

  • Custom Event Handler

    - by Dremation
    I have a function that I'm using while(true) to repeatedly scan memory addresses of an application to detect change. I sleep the thread 1 second between iterations and this helps performance. However, is there a way to create a custom event handler to do away with the loops?

    Read the article

  • Handler vs AsyncTask

    - by Steve
    I'm confused as to when one would choose AsyncTask over a Handler. Say I have some code I want to run every n seconds which will update the UI. Why would I choose one over the other?

    Read the article

  • THE FASTEST Smarty Cache Handler

    - by rob.effect
    Does anyone know if there is an overview of the performance of different cache handlers for smarty? I compared smarty file cache with a memcache handler, but it seemed memcache has a negative impact on performance. I figured there would be a faster way to cache than through the filesystem... am I wrong?

    Read the article

  • Default .NET exception handler

    - by ajs410
    So the other day my C# application crashed. Usually, with a .NET application, if you have an unhandled exception you get a nice error message with a stack trace. However, this time, I got a different dialog that just told me there was an error and offered to attach a Debugger, but there was no stack trace in the dialog and the machine it was running on had no debugger installed. What gives? Why don't I see the default .NET exception handler?

    Read the article

  • Passing window handler for the SFML

    - by Ockonal
    Hello, I'm using SFML Input system for my own application. Here is my code: size_t windowHnd = %MY_WINDOW_HANDLER%; sf::Window MyWindow(windowHnd); const sf::Input& MyInput = MyWindow.GetInput(); cannot convert ‘sf::Window’ to ‘size_t’ in assignment In official documentation I found sf::Window constructor signature: WindowHandle Handle What is the correct way to pass window handler for the SFML?

    Read the article

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