event-handling

.NET: Is creating new EventArgs every time the event fires a good practice?

For example, I have a base event publishing method: protected virtual OnSomeEvent(EventArgs e) { var handler = SomeEvent; if (handler != null) { handler(this, e); // handler(this, new EventArgs());// EDIT: Yes it should be // handler(this,...

Cross-thread event handling in C#

I am working with a framework that runs its own event dispatcher in a separate thread. The framework may generate some events. class SomeDataSource { public event OnFrameworkEvent; void FrameworkCallback() { // This function runs on framework's thread. if (OnFrameworkEvent != null) OnFrameworkEven...

Rewrite lambda extension method

Hi, I've created an extension method that works just like I wanted. I've noticed that somehow the party and property parameters are 'copied' into the lambda expression. This way I do not need to maintain a custom list of editor/party/property associations. However, I need to reset the ButtonEdit's ButtonClick event. Since this one is a...

Handle URL anchor change event in js

How can I write the JavaScript callback code that will be executed on any changes in the URL anchor? For example from http://example.com#a to http://example.com#b ...

Method sleep until event fired

Hi, I have a poker framework for which I am trying to develop a "player" for. Basically I am implementing an object that implements a Player interface defined by the framework. I am trying to put a GUI on top of this player, the way that game play works is that the Dealer invokes the act() method on my player and expects a return type o...

manage addEventListener() and removeEventListener() inside an object

I have a pseudo-class in javascript that has a method to add and remove listeners to two buttons. This is the code: function FirstObj(secondObj){ this.loginButton = document.getElementById("login"); this.logoutButton = document.getElementById("logout"); this.secondObj = secondObj } FirstObj.prototype = { manageListeners : funct...

Can anyone explain event handling in C++ please?

I should mention that i am using Mac OS X, XCode. When a buffer has finished writing to file, it generates an event to tell the gui to read the data off the file. I am not sure what kind of event would i need in this case? Is it possible to do it without using event? Thank you. ...

AS3: Loading SWFs in a for loop

I'm trying to load external SWFs in a for loop, and I have this problem that is really eating me: In the event handler I need to know the filename of the SWF that was loaded, but I can't obtain this. The code below shows what I'm trying to do. Does anybody have any idea? function loadManySWFs(arrayOfFileNames:Array) { for(var i=0;...

How to handle unexpected user promts when using Ruby WIN32OLE to control MSWORD?

Hi! I have implemented a ruby script that is capable of opening a word document through the Ruby WIN32OLE automation library and does a search and replace on some specified string. This script is running as a "service", or it is running on a windows server with a session that is allowed to be running forever, and I just push the 'X' in...

Are there any performance drawbacks to using 'do nothing' default event handlers?

Let's say I have a collection of thousands of objects, all of which implement the following: public event EventHandler StatusChanged = (s,e) => {}; private void ChangeStatus() { StatusChanged(this, new EventArgs()); } If no handlers are subscribed to that event for each object, does using the no-op event handler provide any performa...

Reacting to User Interface events in Visual Studio during a processing loop

Hi, I'm developing in Visual Studio in C++, all managed code. I have a tight processing loop that, theoretically, can run for up to around 30 seconds. During that time, I want the UI to be reactive to any user activity, such as pressing a "Stop" button, or clicking a scroll bar. I know the technique is to peek at the UI queue (in a non...

Creating Events for change in some property value which is user defined

I am creating a custom control and i want to add some properties in it. On few of the properties i want to create some events. Say if i have a property public int Date {get; set;} now if its value is changing i want to trigger a change event. SO how can i add event on this ...

Fire a template child event in current context?

Hello. Is there a way to fire an event from a visual within a DataTemplate in the current context (i.e. Page, Window, UserControl etc.). For example I have a DataTemplate that contains a button or a ListBox. I want that when the button is clicked or when ListBox.SelectionChanged is fired in the ListBox, the event handler should be decl...

Event Handling in winforms with multiple controls.

Lets say we have a form consisting of 20+ controls, for example buttons. We want to create handlers for the On-click event for all of them. The usual way is to go to the designer and double-click each button to have it automatically create the function. Another way is to create them yourself in code, after the InitializeComponent() func...

Event.observe function - observe element by class instead of id

There is prototype js function: Event.observe(element, eventName, handler) here the element means element's ID. Is it possible to put here element's class? I got this element from third party with class attribute only. ...

EventHandler and Memory Leaks

I analyze a VB.NET project and there are some objects(child MDI form) that are disposed, but not removed by the GC. The MemoryProfiler analysis find between others the following: "This instance is disposed and still indirectly rooted by an EventHandler. This often indicates that the EventHandler has not been properly remov...

WithEvents/Handles better that Remove/AddHandler?

Is WithEvents & Handles usage preferable to RemoveHandler & AddHandler? From Memory point of view (remove an added handler after utilization, etc.) Related question. ...

Link Button on ASP.NET user control not firing

Hi I have a user control, which is added to another user control. The nested user control is built up of a GridView, an image button and a link button. The nested user control is added to the outer control as a collection object based upon the results bound to the GridView. The problem that I have is that my link button doesn't work....

PyQt, Qt, one event handler working with many items

Hello, I have a couple of checkboxes on my form, and I don't want to write separate event handler for each, because they all will implement the same logic. Instead I want to write just one event handler that will know about what checkbox has been clicked. E.g. in Delphi I can use it this way: function click_handler(sender): begin ...

How to decode character pressed from jQuery's keydown()'s event handler

I need to figure out which character was typed into a text field from within the handler that is called by jQuery's keydown function. key.which gives me only the keycode, but I need to figure out which ASCII character key represents. How do I do this? ...