Search Results

Search found 15798 results on 632 pages for 'appreciation event'.

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

  • A script that writes errors and should create a event-error

    - by helmich
    this if it works should check the internet connection if there is a connection it does nothing. if there isn't a connection it should write a error in a txtfile if that happend 5 times it should create a error but it doesn't I will show you the whole code that i have now and the piece of code that i want in a loop. I can't get it in the way i want. I want it to creat 1 Event-error after 5 times writing to the file. this is the whole code i will put the code i want in a loop under it strDirectory = "Z:\text2" strFile = "\foutmelding.txt" strText = "De connectie is verbroken" strWebsite = "www.helmichbeens.com" If PingSite(strWebsite) Then WScript.Quit 'Website is pingable - no further action required Set objFSO = CreateObject("Scripting.FileSystemObject") RecordSingleEvent Dim fout For fout = 1 To 5 : Do If fout = 5 Then Exit Do Set WshShell = WScript.CreateObject("WScript.Shell") Call WshShell.LogEvent(1, "Test Event") Loop While False : next '------------------------------------ 'Record a single event in a text file '------------------------------------ Sub RecordSingleEvent If Not objFSO.FolderExists(strDirectory) Then objFSO.CreateFolder(strDirectory) Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, 8, True) objTextFile.WriteLine(Now & strText) objTextFile.Close End sub '---------------- 'Ping my web site '---------------- Function PingSite( myWebsite ) Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" ) objHTTP.Open "GET", "http://" & myWebsite & "/", False objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)" On Error Resume Next objHTTP.Send PingSite = (objHTTP.Status = 200) On Error Goto 0 End Function '----------------------------------------------- 'Counts the number of lines inside the text file '----------------------------------------------- Function EventCount(fout) strData = objFSO.OpenTextFile(strDirectory & strFile,ForReading).ReadAll arrLines = Split(strData,vbCrLf) EventCount = UBound(arrLines) End Function This is the whole code, and it doesnt work correctly becaus it creats a event-log rightaway and it should do that after the script has written 5 times to the textfile here is the code that writes to a textfile Sub RecordSingleEvent If Not objFSO.FolderExists(strDirectory) Then objFSO.CreateFolder(strDirectory) Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, 8, True) objTextFile.WriteLine(Now & strText) objTextFile.Close End sub and here is the code but this part doesnt not work or atleast i think it is this part Dim fout For fout = 1 To 5 : Do If fout = 5 Then Exit Do Set WshShell = WScript.CreateObject("WScript.Shell") Call WshShell.LogEvent(1, "Test Event") Loop While False : next Function EventCount(fout) strData = objFSO.OpenTextFile(strDirectory & strFile,ForReading).ReadAll arrLines = Split(strData,vbCrLf) EventCount = UBound(arrLines) End Function this is the not working part and I don't know what to do anymore so can you please take a look at it tank you very much. btw: this code can be very usefull for a network administrator

    Read the article

  • C#/.NET Little Wonders: The EventHandler and EventHandler&lt;TEventArgs&gt; delegates

    - by James Michael Hare
    Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. In the last two weeks, we examined the Action family of delegates (and delegates in general), and the Func family of delegates and how they can be used to support generic, reusable algorithms and classes. So this week, we are going to look at a handy pair of delegates that can be used to eliminate the need for defining custom delegates when creating events: the EventHandler and EventHandler<TEventArgs> delegates. Events and delegates Before we begin, let’s quickly consider events in .NET.  According to the MSDN: An event in C# is a way for a class to provide notifications to clients of that class when some interesting thing happens to an object. So, basically, you can create an event in a type so that users of that type can subscribe to notifications of things of interest.  How is this different than some of the delegate programming that we talked about in the last two weeks?  Well, you can think of an event as a special access modifier on a delegate.  Some differences between the two are: Events are a special access case of delegates They behave much like delegates instances inside the type they are declared in, but outside of that type they can only be (un)subscribed to. Events can specify add/remove behavior explicitly If you want to do additional work when someone subscribes or unsubscribes to an event, you can specify the add and remove actions explicitly. Events have access modifiers, but these only specify the access level of those who can (un)subscribe A public event, for example, means anyone can (un)subscribe, but it does not mean that anyone can raise (invoke) the event directly.  Events can only be raised by the type that contains them In contrast, if a delegate is visible, it can be invoked outside of the object (not even in a sub-class!). Events tend to be for notifications only, and should be treated as optional Semantically speaking, events typically don’t perform work on the the class directly, but tend to just notify subscribers when something of note occurs. My basic rule-of-thumb is that if you are just wanting to notify any listeners (who may or may not care) that something has happened, use an event.  However, if you want the caller to provide some function to perform to direct the class about how it should perform work, make it a delegate. Declaring events using custom delegates To declare an event in a type, we simply use the event keyword and specify its delegate type.  For example, let’s say you wanted to create a new TimeOfDayTimer that triggers at a given time of the day (as opposed to on an interval).  We could write something like this: 1: public delegate void TimeOfDayHandler(object source, ElapsedEventArgs e); 2:  3: // A timer that will fire at time of day each day. 4: public class TimeOfDayTimer : IDisposable 5: { 6: // Event that is triggered at time of day. 7: public event TimeOfDayHandler Elapsed; 8:  9: // ... 10: } The first thing to note is that the event is a delegate type, which tells us what types of methods may subscribe to it.  The second thing to note is the signature of the event handler delegate, according to the MSDN: The standard signature of an event handler delegate defines a method that does not return a value, whose first parameter is of type Object and refers to the instance that raises the event, and whose second parameter is derived from type EventArgs and holds the event data. If the event does not generate event data, the second parameter is simply an instance of EventArgs. Otherwise, the second parameter is a custom type derived from EventArgs and supplies any fields or properties needed to hold the event data. So, in a nutshell, the event handler delegates should return void and take two parameters: An object reference to the object that raised the event. An EventArgs (or a subclass of EventArgs) reference to event specific information. Even if your event has no additional information to provide, you are still expected to provide an EventArgs instance.  In this case, feel free to pass the EventArgs.Empty singleton instead of creating new instances of EventArgs (to avoid generating unneeded memory garbage). The EventHandler delegate Because many events have no additional information to pass, and thus do not require custom EventArgs, the signature of the delegates for subscribing to these events is typically: 1: // always takes an object and an EventArgs reference 2: public delegate void EventHandler(object sender, EventArgs e) It would be insane to recreate this delegate for every class that had a basic event with no additional event data, so there already exists a delegate for you called EventHandler that has this very definition!  Feel free to use it to define any events which supply no additional event information: 1: public class Cache 2: { 3: // event that is raised whenever the cache performs a cleanup 4: public event EventHandler OnCleanup; 5:  6: // ... 7: } This will handle any event with the standard EventArgs (no additional information).  But what of events that do need to supply additional information?  Does that mean we’re out of luck for subclasses of EventArgs?  That’s where the generic for of EventHandler comes into play… The generic EventHandler<TEventArgs> delegate Starting with the introduction of generics in .NET 2.0, we have a generic delegate called EventHandler<TEventArgs>.  Its signature is as follows: 1: public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e) 2: where TEventArgs : EventArgs This is similar to EventHandler except it has been made generic to support the more general case.  Thus, it will work for any delegate where the first argument is an object (the sender) and the second argument is a class derived from EventArgs (the event data). For example, let’s say we wanted to create a message receiver, and we wanted it to have a few events such as OnConnected that will tell us when a connection is established (probably with no additional information) and OnMessageReceived that will tell us when a new message arrives (probably with a string for the new message text). So for OnMessageReceived, our MessageReceivedEventArgs might look like this: 1: public sealed class MessageReceivedEventArgs : EventArgs 2: { 3: public string Message { get; set; } 4: } And since OnConnected needs no event argument type defined, our class might look something like this: 1: public class MessageReceiver 2: { 3: // event that is called when the receiver connects with sender 4: public event EventHandler OnConnected; 5:  6: // event that is called when a new message is received. 7: public event EventHandler<MessageReceivedEventArgs> OnMessageReceived; 8:  9: // ... 10: } Notice, nowhere did we have to define a delegate to fit our event definition, the EventHandler and generic EventHandler<TEventArgs> delegates fit almost anything we’d need to do with events. Sidebar: Thread-safety and raising an event When the time comes to raise an event, we should always check to make sure there are subscribers, and then only raise the event if anyone is subscribed.  This is important because if no one is subscribed to the event, then the instance will be null and we will get a NullReferenceException if we attempt to raise the event. 1: // This protects against NullReferenceException... or does it? 2: if (OnMessageReceived != null) 3: { 4: OnMessageReceived(this, new MessageReceivedEventArgs(aMessage)); 5: } The above code seems to handle the null reference if no one is subscribed, but there’s a problem if this is being used in multi-threaded environments.  For example, assume we have thread A which is about to raise the event, and it checks and clears the null check and is about to raise the event.  However, before it can do that thread B unsubscribes to the event, which sets the delegate to null.  Now, when thread A attempts to raise the event, this causes the NullReferenceException that we were hoping to avoid! To counter this, the simplest best-practice method is to copy the event (just a multicast delegate) to a temporary local variable just before we raise it.  Since we are inside the class where this event is being raised, we can copy it to a local variable like this, and it will protect us from multi-threading since multicast delegates are immutable and assignments are atomic: 1: // always make copy of the event multi-cast delegate before checking 2: // for null to avoid race-condition between the null-check and raising it. 3: var handler = OnMessageReceived; 4: 5: if (handler != null) 6: { 7: handler(this, new MessageReceivedEventArgs(aMessage)); 8: } The very slight trade-off is that it’s possible a class may get an event after it unsubscribes in a multi-threaded environment, but this is a small risk and classes should be prepared for this possibility anyway.  For a more detailed discussion on this, check out this excellent Eric Lippert blog post on Events and Races. Summary Generic delegates give us a lot of power to make generic algorithms and classes, and the EventHandler delegate family gives us the flexibility to create events easily, without needing to redefine delegates over and over.  Use them whenever you need to define events with or without specialized EventArgs.   Tweet Technorati Tags: .NET, C#, CSharp, Little Wonders, Generics, Delegates, EventHandler

    Read the article

  • Problems with registering click event listener to a frame-element

    - by distractedBySquirrels
    Hi everybody, I ran into a problem with adding an event listener. I wrote a Firefox plugin a while ago for my bachelor thesis. It was based on a different attacker model than you would normally expect. In this scenario the attacker was the service provider (like Facebook, Google,...), who reads all your private data stored on their site (via JS). My final solution was to temporally allow JS (while the page loads and after an user action occured). To observe the interaction I used event listener, which worked very well so far. But last week I noticed that my approach doesn't work with web sites which are using a frameset (I added the event listener to the body...). So I tried to add the listener to the frameset respectively to the frame. But the clicks are only noticed when you actually click on the frame... (eg resize the frame with your mouse) But I want to register clicks on the document loaded inside the frame. I already tried the .frameElement. Sadly it seems that Firefox doesn't like my (or, which is more likely, I'm too stuipd :) ) and claims there are no frames... Could anyone tell me how to add an event listener to the document inside a frame? The web site looks like this: <html> <head> <title>Frameset Test</title> </head> <frameset cols="150,*"> <frame src="nav.html" name="Navigation"> <frame src="main.html" name="Main"> </frameset> </html> This was my first bigger projekt with Mozilla so this could be a really dumb failure of mine... I hope you guys can help me. Thanks in advance. Sebastian

    Read the article

  • jQuery problem with change event and IE8

    - by Marcus
    There is a bug in jQuery 1.4.2 that makes change event on select-element getting fired twice when using both DOM-event and a jQuery event, and this only on IE7/8. Here is the test code: <html> <head> <script src="http://code.jquery.com/jquery-1.4.2.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery(".myDropDown").change(function() { }); }); </script> </head> <body> <select class="myDropDown" onchange="alert('hello');"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> </body> </html> Ticket to actual bug: http://dev.jquery.com/ticket/6593 This causes alot of trouble for us in our application cause we use both ASP.NET-events mixed with jQuery and once you hook up a change event on any element every select (dropdown) gets this double firing problem. Is there anyone who knows a way around this in the meantime until this issue is fixed?

    Read the article

  • flash as3 document class and event listeners

    - by Lee
    I think i have this document class concept entirly wrong now, i was wondering if someone mind explaining it.. I assumed that the above class would be instantiated within the first frame on scene one of a movie. I also assumed that when changing scenes the state of the class would remain constant so any event listeners would still be running.. Scene 1: I have a movieclip named ui_mc, that has a button in for muting sound. Scene 2: I have the same movie clip with the same button. Now the eventListener picks it up in the first scene, however it does not in the second. I am wondering for every scene do the event listeners need to be resetup? If that is the case if their an event listener to listen for the change in scene, so i can set them back up again lol.. Thanks in advance.. package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.media.Sound; import flash.media.SoundChannel; public class game extends MovieClip { public var snd_state:Boolean = true; public function game() { ui_setup(); } public function ui_setup():void { ui_mc.toggleMute_mc.addEventListener(MouseEvent.CLICK, snd_toggle); } private function snd_toggle(event:MouseEvent):void { // 0 = No Sound, 1 = Full Sound trace("Toggle"); } } }

    Read the article

  • Asynchronous event loop design and issues.

    - by Artyom
    Hello, I'm designing event loop for asynchronous socket IO using epoll/devpoll/kqueue/poll/select (including windows-select). I have two options of performing, IO operation: Non-blocking mode, poll on EAGAIN Set socket to non-blocking mode. Read/Write to socket. If operation succeeds, post completion notification to event loop. If I get EAGAIN, add socket to "select list" and poll socket. Polling mode: poll and then execute Add socket to select list and poll it. Wait for notification that it is readable writable read/write Post completion notification to event loop of sucseeds To me it looks like first would require less system calls when using in normal mode, especially for writing to socket (buffers are quite big). Also it looks like that it would be possible to reduce the overhead over number of "select" executions, especially it is nice when you do not have something that scales well as epoll/devpoll/kqueue. Questions: Are there any advantages of the second approach? Are there any portability issues with non-blocking operations on sockets/file descriptors over numerous operating systems: Linux, FreeBSD, Solaris, MacOSX, Windows. Notes: Please do not suggest using existing event-loop/socket-api implementations

    Read the article

  • fullCalendar: Implementing a custom event fetcher using event as function

    - by Nick-ACNB
    If I specify a json feed, the events are re-fetched everytime and the fetching time shows the item appearing which causes a delay which is undesirable (at least after initial fetch was done). I am using the latest version from gitHub 1.4.6. The lazyFetching property seems to only work when you change views and you previously fetched for example a month and are drilling down to week/day which is unusable since I only use agendaDay. Here is what I am trying to achieve: $("#calendar").fullCalendar({ events: function(start, end, callback) { $.getJSON( "/GetEvents", { start: start.valueOf() }, function(data, textStatus) { $.each(data, function(i, event) { //Goal here is to only add items that aren't already rendered. if ($("#calendar") .fullCalendar('clientEvents', event.id)=="") $("#calendar").fullCalendar('renderEvent', event, true); }); } ); }); The goal is to use the sticky property in the renderEvent method so that on-screen they aren't re-rendered if they we're previously fetched. I omitted a part where I manually delete those that we're deleted and modify those that we're updated since I am in multi-user settings but you get the point. My issue is that they are fetched once and added. But once I change day and come back, they don't render even if I used sticky... has anyone gotten this error or did I code anything wrong? Also, is this a wrong way to go? I will consider any input. :) Thank you very much.

    Read the article

  • Help with c# event listening and usercontrols

    - by Jen
    OK so I have a page which has a listview on it. Inside the item template of the listview is a usercontrol. This usercontrol is trying to trigger an event so that the hosting page can listen to it. My problem is that the event is not being triggered as the handler is null. (ie. EditDateRateSelected is my handler and its null when debugging) protected void lnkEditDate_Click(object sender, EventArgs e) { if (EditDateRateSelected != null) EditDateRateSelected(Convert.ToDateTime(((LinkButton)frmViewRatesDate.Row.FindControl("lnkEditDate")).Text)); } On the item data bound of my listvew is where I'm adding my event handlers protected void PropertyAccommodationRates1_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { UserControls_RatesEditDate RatesViewDate1 = (UserControls_RatesEditDate)e.Item.FindControl("RatesViewDate1"); RatesViewDate1.EditDateRateSelected += new UserControls_RatesEditDate.EditDateRateEventHandler(RatesEditDate1_EditDateRateSelected); RatesViewDate1.PropertyID = (int)Master.PropertyId; if (!String.IsNullOrEmpty(Accommodations1.SelectedValue)) { RatesViewDate1.AccommodationTypeID = Convert.ToInt32(Accommodations1.SelectedValue); } else { RatesViewDate1.AccommodationTypeID = 0; } RatesViewDate1.Rate = (PropertyCMSRate)((ListViewDataItem)e.Item).DataItem; } } My event code all works fine if the control is inside the page and on page load I have the line: RatesEditDate1.EditDateRateSelected += new UserControls_RatesEditDate.EditDateRateEventHandler(RatesEditDate1_EditDateRateSelected); But obviously I need listen for events inside the listviewcontrols. Any advice would be greatly appreciated. I have tried setting EnableViewState to true for my listview but that hasn't made a difference. Is there somewhere else I'm supposed to be wiring up the control handler? Note - apologies if I've got my terminology wrong and I'm referring to delegates as handlers and such :)

    Read the article

  • ASP .NET Added Event Handlers to buttons on Page_Load. Event handlers do not fire the first click, b

    - by John
    Background: I am customizing an existing ASP .NET / C# application. It has it's own little "framework" and conventions for developers to follow when extending/customizing its functionality. I am currently extending some of it's administrative functionality, to which the framework provides a contract to enforce implementation of the GetAdministrationInterface() method, which returns System.Web.UI.Control. This method is called during the Page_Load() method of the page hosting the GUI interface. Problem: I have three buttons in my GUI, each of which have been assigned an Event Handler. My administration GUI loads up perfectly fine, but clicking any of the buttons doesn't do what I expect them to do. However, when I click them a second time, the buttons work. I placed breakpoints at the the beginning of each event handler method and stepped through my code. On the first click, none of the event handlers are triggered. On the second click, they are triggered. Any ideas? Example of Button Definition Button btn = new Button(); btn.Text = "Click Me Locked Screen"; bth.Click += new EventHandler(Btn_Click); Example of Event Handler Method Definition void Btn_Click(object sender, EventArgs e) { // Do Something }

    Read the article

  • Is there a jQuery Equivalent of YUI 2 Custom Event Publish/Subscribe Event Model?

    - by Abe
    Hello! I learned how to develop in Javascript using the YUI 2 library and was wondering if there is a jQuery equivalent of Custom Events (http://developer.yahoo.com/yui/event/#customevent) Specifically, I want to be able to define custom events without having to attach the listeners initially. In YUI, I would create a page class and declare different custom events that can be subscribed to. Below is some example code to demonstrate what I want to do, but with jQuery function ListPage() { var me = this; this.initEvent = new YAHOO.util.CustomEvent("initEvent"); this.init = function() { // initialize events, DOM, etc this.initEvent.fire(me); } } In application Javascript, I would then like to subscribe to the initEvent. var page = new ListPage(); page.initEvent.subscribe( function (type, args) { // do stuff here } ); page.init(); Are there any tutorials/examples of something this in jQuery? I understand I can do something similar using bind() and trigger(), but the impression I get is I have to pass in the event handler when I call bind(). Is it possible in jQuery to create the custom event, but pass in the event handler later? I hope my question makes sense. thanks!

    Read the article

  • jqGrid inline editing event on "Esc" cancel

    - by gurun8
    Does anyone know if jqGrid inline editing throws events that can be handled? The following code is a simple example of what I'm trying to accomplish: jQuery('#list').jqGrid('editRow', 0, true, false, false, false, {onClose: function(){alert('onClose')}}, reloadGrid); I'd like to be able to handle an "Esc" cancel event. The onClose event is available with Form Editing: www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing but doesn't work with inline editing and the Inline Editing documentation doesn't supply anything event wise other than the extraparam option which is very unspecific: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing I haven't been able to figure out how to utilize the extraparam options. Suggestions?

    Read the article

  • Python Tkinter - Edit external object within event handler?

    - by M3RPHY
    Hey all, As the title says, I'm grabbing the cursor location within a motion triggered event handler in Tkinter. I'd like to update an existing label widget with the location, however I cannot for the life of me figure out how to edit the label's text field (or any external object for that matter) within the event handler. From what I understand, event is the only argument passed to the handler, which means I can't pass the label object. How do I access objects outside of the handler? Apologize for the noobish question as I'm a C programmer new to Python. Thanks!

    Read the article

  • Cancel Leave Event when closing

    - by DiegoMaK
    I have got a textbox on a form with a method being called from the txPredio_Leave event. My problem is that is the user has focus on the textbox and then close the form by clicking the little X close icon in the top corner or by calling this.ActiveMdiChild.Close(); or by calling private void mnucerrarTodas_Click(object sender, EventArgs e) { foreach (Form form in this.MdiChildren) { form.Close(); } } The txPredio leave execute the method.. then i need doesn't excute this method when the form is closing. i have think that one solution could be ask in leave event if form is closing private void txPredio_Leave(object sender, EventArgs e) { if(!form is closing)//pseudo code Check_Load_Predio(); } or other solution could be private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { //code for cancel the txPredio_Leave event } Solution Here Doesn´t work for me. Then I need one solution for my problem. Thanks in advance

    Read the article

  • Unable to retrieve the complete description string of the event log record

    - by Santosh Pillai
    Hi All, I have an MFC application that reads and displays event log records using the ::ReadEventLog() API. The problem is with reading the "Description" message string of the event log record. The MFC application is unable to read the complete "Description" message string and displays only some part of it. However the Windows System Event Log Viewer reads and displays the complete "Description" message string correctly. I have ensured that my MFC application reads the entire "Description" message string by retrieving all the strings as provided by the "NumStrings" and "StringOffset" member variables of the EVENTLOGRECORD structure and merging all of them. Also as mentioned in MSDN my application loads the Source Name specific message library file (whose path is specified in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application[SourceName]) that further contains additional message string information and merges it with the earlier read strings. I am still unable to get the entire "Description" message string. Please provide any help towards resolving the issue. Regards, Santosh.

    Read the article

  • Strategy for unsubscribing event handlers

    - by stiank81
    In my WPF application I have a View that is given a ViewModel, and when given this View it adds event handlers to the ViewModel's PropertyChanged event. When some action occur in the GUI I remove the View and add another View to the holding container - where this new one is bound to the same ViewModel. After this has happened the old View still keeps handling PropertyChanged events in the ViewModel. I'm assuming this happens because the View hasn't been collected by the Garbage Collector yet, and therefore is alive? Well - I need it to stop. My assumption is that I need to manually detach the event handler from the ViewModel? Is there a best-practice on how to handle this?

    Read the article

  • Programmatically manipulating DOM element value doesn't fire onchange event

    - by Johan Fredrik Varen
    Hi all. I've got a hidden form field, and when a button gets pressed the value of the hidden field is changed. Now, I've added an observer to the hidden field, listening for changes to occur. For some reason, though, the event listener never kicks in, even though the value of the hidden element changes. I'm using Prototype and Firefox 3.6. The code looks roughly like this: button.observe('click', function(event) { hiddenField.setValue(someValue); }); hiddenField.observe('change', function(event) { alert('It works!'); }); Does anyone have a clue why the latter observer doesn't execute? Thanks!

    Read the article

  • GWT removeHandler on first event notification

    - by Keith
    I want to remove a GWT event handler the first time I receive an event. I also want to avoid polluting my class with tracking registration objects that aren't really necessary. I currently have it coded as: final HandlerRegistration[] registrationRef = new HandlerRegistration[1]; registrationRef[0] = dialog.addFooHandler(new FooHandler() { public void onFoo(FooEvent event) { HandlerRegistration removeMe = registrationRef[0]; if(removeMe != null) { removeMe.removeHandler(); } // do stuff here } }); but the use of registrationRef makes the code less readable. Is there a better way to do this without adding variables to my class?

    Read the article

  • Custom event listener on Android app

    - by Bilthon
    Hi everybody, I need to set up a simple event listener to refresh a listview from once in a while. The problem is I don't know how could I generate an event. I know that for events like key or button pressing I just need to implement the handler. But in this specific case I actually need to generate the event, which will be fired everytime another running thread of my app wakes up and refreshes it's list of news from a rss feed. I've done everything, but got stucked in here. Can I get any suggestion or link with some more info on how to implement this? Thanks Nelson R. Perez

    Read the article

  • MooTools - Programmatically fired events not working with event delegation

    - by Anurag
    Would really appreciate if anyone can help me figure out why I am unable to fire events programmatically when using event delegation in MooTools (from the Element.Delegation class). There is a parent <div> that has a change listener on some child <input> elements. When the change event is triggered by user actions, the handler on the parent div gets triggered, but when I fire it programmatically with fireEvent on any child input, nothing happens. The basic setup is: html <div id="listener"> <input type="text" id="color" class="color" /> ????????????????????????????????????????????????????????????????</div>??????????? js $("listener").addEvent("change:relay(.color)", function() { alert("changed!!"); }); $("color").fireEvent("change"); // nothing happens The event handler on the parent div does not get called. Any help is appreciated. Cheers!

    Read the article

  • Using threads and event handlers within a WCF Web Service

    - by user368984
    While making a WCF Web Service, I came across a problem while using a method with a webbrowser control. The method starts a thread and uses a webbrowser control to fill in some forms and click further, waiting for a event handler to fire and return a answer I need. The method is tested and works within its own enviroment, but used in a WCF Web Service enviroment, the event handlers just won't fire. A result of that is the waiting manualresetevent not ending. Is this because of the new thread or because of the bad event handling of the web service? If yes, what is a reasonable solution?

    Read the article

  • Trigger Event after values have been commited for validation purposes

    - by www.jefferyfernandez.id.au
    I have a Flex component with a form and on creationComplete, I load some data onto the form textInputs. After the Form TextInputs have got their values, I want to trigger an event so the Parent of the component can validate the values on the TextInputs and based on the validation results, I perform some enable/disable of other interfaces. I have the following dispatch code: this.dispatchEvent(new PersonalDetailsEvent(PersonalDetailsEvent.LOADED_DATA_EVENT)); The event is dispatched and is captured by the parent. But upon performing the validation, some TextInputs always fail the validation. I thought it could be because of a race condition and so I used callLater() with same results. So in the end I am now using a timer to dispatch the event which is not ideal. Does anyone have a solution to this problem. It is really annoying that a timer needs to be used for this scenario.

    Read the article

  • What are the caveats of the event system built on Messenger rather than on classic .NET events?

    - by voroninp
    MVVM Light and PRISM offer messenger to implement event system. the approximate interface looks like the following one: interface Messanger { void Subscribe<TMessageParam>(Action<TMessageParam> action); void Unsubscribe<TMessageParam>(Action<TMessageParam> action); void Unsubscribe<TMessageParam>(objec actionOwner); void Notify<TMessageParam>(TMessageParam param); } Now this model seems beneficial comparing to classic .net events. It works well with Dependency Injection. Actions are stored as weak references so memory leaks are avioded and unsubscribe is not a must. The only annoyance is the need to declare new TMessageParam for each specific message. But everything comes at a cost. And what I'm really worried about is that I see no shortcomings of this approach. Has anoyne the experience of some troubles with this design pattern?

    Read the article

  • Assign an existing click event function to another click event using jquery

    - by Peter Delahunty
    Ok so i have some html like this: <div id="navigation"> <ul> <li> <a>tab name</a> <span class="delete-tab">X</span> </li> <li> <a>tab name</a> <span class="delete-tab">X</span> </li> <li> <a>tab name</a> <span class="delete-tab">X</span> </li> <li class="selected"> <a>tab name</a> <span class="tab-del-btn">X</span> </li> </ul> </div> I then have javascript that is excuted on the page that i do not control (this is in liferay portal). I want to then manipulate things afterwards with my own custom javascript. SO... For each of the span.delete-tab elements an on-click event function has been assign earlier. It is the same function call for each span. I want to take that function (any) and call it from the click event of the span.tab-del-btn ? This is what i tried to do: var navigation = jQuery('#navigation'); var navTabs = navigation.find('.delete-tab'); var existingDeleteFunction = null; navTabs.each(function (i){ var tab = jQuery(this); existingDeleteFunction = tab.click; }); var selectedTab = jQuery('#navigation li.selected'); var deleteBtn = selectedTab.find('.tab-del-btn'); deleteBtn.click(function(event){ existingDeleteFunction.call(this); }); It does not work though. existingDeleteFunction is not the original function it is some jquery default function. Any ideas?

    Read the article

  • jQuery event trigger - cancelable event

    - by Dismissile
    I have created a jquery plugin which is triggering an event: $.fn.myplugin = function(options) { this.on("foo.myplugin", options.foo); this.on("bar.myplugin", options.bar); }; I want to check if foo has been canceled by a user and prevent bar from being triggered: // trigger foo this.trigger("foo.myplugin"); // how do I check if foo was canceled if( !fooCanceled ) { this.trigger("bar.myplugin"); } How can I check if foo was canceled to prevent bar from being triggered? jQuery UI does something similar to this, but it did not work when I tried: if (this._trigger("search", event) === false) { return; } I tried something similar to this: if( this.trigger("foo.myplugin") === false ) { return; } this.trigger("bar.myplugin"); But bar was still being triggered.

    Read the article

  • Drupal Event/Calendar Module not storing event time

    - by Selino
    Hello, all. I have installed a fresh copy of Drupal on an Xampp server. Within that install is a collection of modules for creating an event calendar. There's actually a great instructional video at http://www.youtube.com/watch?v=qO4TeEydtMs for getting all the necessary fields up. So far everything is working except... the events won't store the time as stated in the edit field. No matter what I do in the edit mode as admin or otherwise the time always says 12pm and the event on the calendar says "All Day". I know this is pretty obscure but I figured why not try and ask. Thanks.

    Read the article

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