event-handling

Event Handler performance

主宰稳场 提交于 2019-12-20 10:34:35
问题 I have a performance problem. I create 100 new buttons and I want to assign an Click Event Handler. I execute this code for about 100 times: Buttons[i].Button.Click += new System.EventHandler(Button_Click); It takes about 2sec to complete. I have a lot of other event assignments in the same function, but they all take only some millisecond to execute. So I have transformed my code in Buttons[i].Button.MouseUp += new System.Windows.Forms.MouseEventHandler(Button_Click); Now the code is fast

How often does the AngularJS digest loop run?

 ̄綄美尐妖づ 提交于 2019-12-20 09:42:45
问题 When discussing the merits of AngularJS, two-way data binding is often touted as a major benefit of Angular over other JS frameworks. Digging deeper, the documentation suggests this process is done through dirty-checking rather than through event-driven measures. At first, it seems that the digest-loop works by having a method fire off in the background at periodic intervals, checking all the $watch es during each cycle. However, reading further, it seems that the digest-loop is actually

How to get tcmid of currently logged user in Tridion?

大兔子大兔子 提交于 2019-12-20 07:50:46
问题 private void Subscribe() { EventSystem.Subscribe<User, LoadEventArgs>(GetInfo, EventPhases.Initiated); } public void GetInfo(User user, LoadEventArgs args, EventPhases phase) { TcmUri id = user.Id; string name = user.Title; Console.WriteLine(id.ToString()); Console.WriteLine(name); } I wrote above code and add the assembly in config file in Tridion server but no console window is coming on login of a user 回答1: The event you were initially subscribing to is the processed phase of any

How to read input in a html page with javascript without focus in one field

偶尔善良 提交于 2019-12-20 06:30:39
问题 I want to ask how can someone read keystrokes while in a html page without having focus in a particular field. Is there some event that i can hook a method that reads input? Thanks in advance. PS. We use JQuery if that helps. 回答1: Use document.onkeypress (or the siblings onkeydown and onkeyup ): document.onkeypress = function (event) { ... }; jQuery offers for these events, e.g., $(document).keypress (function (event) { ... }); This will catch all key press events on your site. Inside the

Event handler not firing using AddHandler

眉间皱痕 提交于 2019-12-20 06:11:53
问题 I have a form with about 40 checkboxes. Once a checkbox is checked, the div control's property should be changed from "none" to "block" or vice versa. I don't get an error, but the checkedchanged event isn't handled. Here is the markup: <tr> <td class="sectionSubHeader lightgrey"> <asp:CheckBox ID="chkbxCOMAEFund" AutoPostBack="true" runat="server" /> COM Academic Excellence Fund - Endowed </td> </tr> <tr> <td> <ul class="boldDetail"> <li>Financial Need</li> </ul> </td> </tr> <tr> <td colspan

Open MediaPlayer - event unhandled in Thread

混江龙づ霸主 提交于 2019-12-20 05:36:07
问题 I'm trying to create a media player (with Media.MediaPlayer() class) and for this I am using a thread to process the songs that are loaded by the user using the OpenFileDialog. I am using the next code to start the process the songs: public static List<MediaFile> MediaList = new List<MediaFile>(); public static Queue<String> MediaFilesQueue = new Queue<String>(); public static void AddMediaFilesToMediaList() { String pathToFile; while (MediaFilesQueue.Count > 0) // all the files are loaded

How to fix the event delay

ⅰ亾dé卋堺 提交于 2019-12-20 05:21:44
问题 I'm making a table reservation system for a school project, and I'm using a list of PictureBoxes to represent the tables. To these PictureBoxes I have linked a hover event, and when I hover the BackColor property is changed. List<PictureBox> pb = new List<PictureBox> { pictureBox1, pictureBox2, pictureBox3}; foreach (PictureBox p in pb) { p.BorderStyle = BorderStyle.Fixed3D; p.BackColor = Color.White; p.MouseHover += new EventHandler(mouseOn); } private void mouseOn(object sender, EventArgs e

How to fix the event delay

谁说我不能喝 提交于 2019-12-20 05:21:25
问题 I'm making a table reservation system for a school project, and I'm using a list of PictureBoxes to represent the tables. To these PictureBoxes I have linked a hover event, and when I hover the BackColor property is changed. List<PictureBox> pb = new List<PictureBox> { pictureBox1, pictureBox2, pictureBox3}; foreach (PictureBox p in pb) { p.BorderStyle = BorderStyle.Fixed3D; p.BackColor = Color.White; p.MouseHover += new EventHandler(mouseOn); } private void mouseOn(object sender, EventArgs e

Updating the listbox after adding a new item

二次信任 提交于 2019-12-20 05:11:15
问题 I am using WPF and C# I have a button that opens a window, which also includes a button that adds an User object item to a listbox and I want the listbox index to be updated after insertion. I understood that the solution is about using observable class of INotifyCollectionChanged but actually I dont know how and where to use them. Can you help me on determining what and where to implement, register, fire etc. Edit: I succeeded this by Quartermeister's help where my User object is collected

Object disposal and garbage collection prior to event triggering

余生长醉 提交于 2019-12-20 04:12:20
问题 A piece of code was brought up by someone I was talking to: private void DownloadInformation(string id) { using (WebClient wc = new WebClient()) { wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCompleted); wc.DownloadStringAsync(new Uri("http://www.fake.com/" + id)); } } The above is a simplified version of this: (I have the author's permission to post the image.) What bothers me about that code is that an event handler is attached, DownloadStringAsync()