eventhandler

How do I make sure no handlers are attached to an event?

I am adding an event handler like this: theImage.MouseMove += new MouseEventHandler(theImage_MouseMove); but in my application, this code gets run every time the page is shown, so I want to attach the event handler only once, but how can I tell if a handler has been set yet or not, something like this: if(theImage.MouseMove == null) ...

Invoking EventHandler generic, TargetParameterCountException

Hi, I have a DirectoryMonitor class which works on another thread. It has the following events declared: public class DirectoryMonitor { public event EventHandler<MonitorEventArgs> CreatedNewBook; public event EventHandler ScanStarted; .... } public class MonitorEventArgs : EventArgs { public Book Book { get; set; } } ...

Custom Event Handler

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? ...

C#: Need one of my classes to trigger an event in another class to update a text box

Total n00b to C# and events although I have been programming for a while. I have a class containing a text box. This class creates an instance of a communication manager class that is receiving frames from the Serial Port. I have this all working fine. Every time a frame is received and its data extracted, I want a method to run in m...

There is no web named - Sharepoint Event Hander

I activated following code with feature (web level scope). Now when i add an item to any document library it should create a folder "". No folder is created and no error is given either. can anyone see what's is going on? I got the following from the log file. I found similar code all over google so I am kinda puzzled why is not working...

Extending DataList to accept a new InsertCommand from LinkButtons

I'm trying to subclass DataList to accept a new Command from embedded LinkButtons. Here's my abstract class: public abstract class BaseFieldGroup : DataList { public const string InsertCommandName = "Insert"; public event DataListCommandEventHandler InsertCommand { add { base.Events.AddHandler(Ev...

CloseHandler<Window> and Window.ClosingHandler() working differently in IE

It seems that CloseHandler and Window.ClosingHandler() are not working or are not triggering the events in the same way under IE as opposed to Firefox. Window.addWindowClosingHandler(new Window.ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { ...

C# Simple Event Handler for Setting Alarm

Why does the following line "alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound);" gives me "An object reference is required for the non-static field, method, or property 'AlarmClock.Alarm.alarm_Sound(object, System.EventArgs)'" public static void Main(string[] args) { Alarm alarm = new Alarm(new DateTime(2010, 4, 7, 2...

Question regarding to value/reference type of events

Hi, On the MSDN, I have found following: public event EventHandler<MyEventArgs> SampleEvent; public void DemoEvent(string val) { // Copy to a temporary variable to be thread-safe. EventHandler<MyEventArgs> temp = SampleEvent; Is it reference? If so I do not understand its meaning as when SampleEvent became null, so does the te...

VS/C#: Can I be notified of every event that gets handled while debugging?

I am currently troubleshooting a large and unwieldy GUI-based tool in Visual Studio, and was wondering whether there is any way to get some kind of notification (either by writing to the console or through a third-party tool) whenever any handled event occurs. This would make it a lot easier to track down what precisely is going on while...

Actionscript 3 (Flex) - How do you clone an object including copying the event handlers/listeners?

I want to clone an object of a class (whose source code I do not have) and copy all of the associated event handlers from the original object to the new cloned object. Does anyone know how I can do that? I know how to copy the properties from the original to the new, but can I iterate over all the event handlers and add them to the new o...

jQuery and ASP.NET drop down problem

I have a drop down in an ASP.NET page. Whenever the value of the drop down changes an ASP.NET AJAX request is made to the server. I also attached a jQuery "change" event handler to that list to execute some code when the value is changed. So, probably two different event handlers are being attached to the same drop down, and it's causing...

Help understanding .NET delegates, events, and eventhandlers

Hello, In the last couple of days I asked a couple of questions about delegates HERE and HERE. I confess...I don't really understand delegates. And I REALLY REALLY REALLY want to understand and master them. (I can define them--type safe function pointers--but since I have little experience with C type languages it is not really helpfu...

Are there any shortcuts/easier(VB) style way for raising events in C#?

Example in VB I have a worker class Public Class worker Public Event EventNumber1(ByVal messages As Dictionary(Of Integer, String)) Public Event EventNumber2(ByVal message As String) Public Sub CallEventNumber1() Dim dict As New Dictionary(Of Integer, String) dict.Add(1, "EventNumber1 First message") ...

Which event handler to use to record leaving page - onunload or onbeforeunload?

Hi all, Having not any answers to my previous questions about using javascript to measure page turn times, I'm going to start writing my own code (!). To measure the length of tie it takes, I'm proposing dropping a cookie containing a timestamp when the user browses away from a page, then in a subsequent page, comparing that time with ...

c# winforms events restore textbox contents on escape

Using c# in 2008 Express. I have a textbox containing a path. I append a "\" at the end on Leave Event. If the user presses 'Escape' key I want the old contents to be restored. When I type over all the text and press 'Escape' I hear a thump and the old text isn't restored. Here what I have so far ... public string _path; public ...

Call a function when "event.GetFrom(m_cpVoice)==S_OK" (ergo when event happens) [SAPI 5.1 and C++]

Hello, I'm doing a project with a 3D model, that speaks. So, I'm using SAPI 5.1, and I want to call a function asynchronously when there's a Viseme event (in order to play the animation related to). How could I do it? Thank you very much. Note: I use : hRes = m_cpVoice->Speak(L"All I want is to solve this problem", SPF_ASYNC , NULL...

creating link button dynamically and setting Click event to EventHandler...not working

I'm creating a paging class and trying to allow for some dynamic configuration for the method to call when Next/Previous links are clicked. The class looks like this: public class Pager { public int StartIndex { get; set; } public int Range { get; set; } public int NumRows { get; set; } public event EventHandler Paging;...

MFC component defocus event handler

Hello, Is there a standard way to handle MFC Edit box defocus event? I mean if I click on the box enter something and then move on on the other component handling event gets fired? Thank you for any help! ...

Why does my sharepoint web part event handler lose the sender value on postback?

I have a web part which is going to be a part of pair of connected web parts. For simplicity, I am just describing the consumer web part. This web part has 10 link buttons on it. And they are rendered in the Render method instead ofCreateChildControls as this webpart will be receiving values based on input from the provider web part. E...