event-handling

Clearing subscriptions: What will break this self-cleaning event publisher?

烈酒焚心 提交于 2019-12-13 03:29:52
问题 I've been studying garbage collection and event handlers, and in my studies, I came across some code that appears to clean all subscriptions, anonymous or otherwise, from an event handler. The code is as follows: public event CustomEventHandler customHandler; ... ///Something somewhere subscribes to the customHandler ... ///Method used for cleanup void ClearSubscriptions(CustomEventHandler handler){ if(handler == null){return;} Delegate[] delegates = handler.GetInvocationList(); foreach

Event capturing vs. bubbling with a contentEditable div

被刻印的时光 ゝ 提交于 2019-12-13 03:14:42
问题 I am dealing with a content editable div and I need to deal with capturing key strokes both before and after the character has been added to the div. My understanding of capturing vs. bubbling is that the event gets captured at the highest level in the dom tree first then passes it down, while for bubbling it starts at the lowest level and bubbles up the tree. Based on that understanding, I thought that if I added an event listener at the capturing phase, the content of the editable div would

Detect change, if input-text is changed by JavaScript

天大地大妈咪最大 提交于 2019-12-13 03:13:41
问题 Summary- I am working on a text-comparison tool. I have two functions - an excel-parser, which fetches data from excel file and changes the input-text dynamically/programmatically. - a text comparison function listens for any changes in the input field and runs text-comparison logic. I am new to jQuery but have tried JS with eventListeners, oninput, onchange, onpaste, etc. Note: The following code snippet explains the situation. However, there is no such button click. var a = document

Integrating two event handling programs in Python

£可爱£侵袭症+ 提交于 2019-12-13 02:52:46
问题 I have two programs in Python. Let's call them Prog1.py and Prog2.py . Prog1 is helping me get live data from an external device. As of now, as and when it gets the data it prints it on the screen. There is a while loop running where in each iteration it prints out the new set of data acquired. Now Prog2 is a Python program built using PyQtGraph which is intended to plot the data real time like that of a monitor. As of now what Prog2 does is that (that is, when it is run separately), it plots

Removing Visual Studio 2010 Event Handlers

耗尽温柔 提交于 2019-12-13 02:39:53
问题 I am working on a project that I had left all the controls with default names until recently. Multiple times at the start of the project, I accidentally double-clicked something and it created an event handler for that control. At the time I didn't know how to remove them, because Ctrl+Z would undo far more than I wanted. I now know that I can view and refactor the events that are being used by a control in the Events section of the Properties windows. I have mostly fixed these problems but I

Find control that caused ContextMenuStrip menu to be shown

无人久伴 提交于 2019-12-13 02:11:57
问题 I've read a few articles on SO: How to detrmine the control that cause ContextMenuStrip Getting the control of a context menu and a couple others that suggested use of the SourceControl property.. but none work in this context: I have a ContextMenuStrip that has a child ToolStripMenuItem - this code from the windows forms designer generated section: // _tileContextMenuStrip // this._tileContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tileKindToolStripMenuItem,

Why is KernelEvents::TERMINATE blocking the response to the user?

梦想的初衷 提交于 2019-12-13 02:07:51
问题 In a Silex application running on HVVM I have setup a dummy event listener on Kernel TERMINATE : $app['dispatcher']->addListener( KernelEvents::TERMINATE, function () use ($app) { usleep(10000000); $app['logger']->alert("I AM REGISTERED!"); } ); I was expecting my application to render the response as fast as possible within a second and after 10s I expected the message "I AM REGISTERED" to appear in my log. Yet strangely the response is sent after the event has been executed, meaning the

Visual Basic - how to force event to fire

折月煮酒 提交于 2019-12-13 01:57:15
问题 I'm new to VB (using VBA, actually) and I would like to force an event to fire. Specifically, I am updating the value in a textbox and I would like to call that textbox's AfterUpdate() event. Private Sub cmdCreateInvoice_Click() Me.txtInvDate = '11/01/10' Me.txtInvDate.AfterUpdate End Sub During run time, I get an error that says "Compile Error: Invalid Use of Property". If I try something similar, but with the click event (ex: cmdCreateInvoice.Click), which does NOT have a property that

eventhandler and postback (.net)

让人想犯罪 __ 提交于 2019-12-13 01:24:57
问题 I have a simple asp.net-Page with a button. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" MasterPageFile="~/MasterPage.master"%> <asp:Content runat="server" ID="content" ContentPlaceHolderID="ContentPlaceHolder1"> <asp:Button runat="server" ID="btn1" Text="Click me" /> </asp:Content> with Code: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { btn1.Click += new EventHandler(Btn1_Click); } } protected void Btn1_Click

C# Adding arguments to a 3rd party delagate signature

五迷三道 提交于 2019-12-13 01:14:16
问题 I have a 3rd party delegate with a "void Method (string)" signature. The problem is I want/need to pass extra additional information to MySubscribedMethod (Lets say MyIntArg for simplicity). I know this information at the time of the subscription, but I obviously not allowed to alter the MySubscribedMethod parameter list. ThirdPartyClass.ThirdPartyDelagate += MySubscribedMethod; // Want to provide MyIntArg public void MySubscribedMethod(string Arg) {} // Would like to receive MyIntArg Does