eventargs

Are EventArg classes needed now that we have generics

时光总嘲笑我的痴心妄想 提交于 2019-11-30 04:47:21
With generics, is there ever a reason to create specific derived EventArg classes It seems like now you can simply use them on the fly with a generic implementation. Should i go thorugh all of my examples and remove my eventArg classes (StringEventArgs, MyFooEventArgs, etc . .) public class EventArgs<T> : EventArgs { public EventArgs(T value) { m_value = value; } private T m_value; public T Value { get { return m_value; } } } What you are describing are essentially tuples , grouped values used for a particular purpose. They are a useful construct in functional programming and support that

Jquery - Pass asp button command argument with jquery

China☆狼群 提交于 2019-11-29 07:30:46
I have asp button: <asp:button ID="btn1" runat="server" CommandArgument="" CssClass="btn1" OnClick="button_click"></asp:button> and script: $("a").click(function () { var val = $(this).attr('id').toString(); $('.btn1').attr('CommandArgument',val); alert($('.btn1').attr('CommandArgument').toString()); $('.btn1').click(); }); after click it alerts me command argument. But on next step - when i trigger btn1 click with jquery it goes to codebehind and command argument is empty. Can i pass somehow command argument with jquery? I've tried to save value to global variables but after postback they're

Are EventArg classes needed now that we have generics

我的梦境 提交于 2019-11-29 02:14:40
问题 With generics, is there ever a reason to create specific derived EventArg classes It seems like now you can simply use them on the fly with a generic implementation. Should i go thorugh all of my examples and remove my eventArg classes (StringEventArgs, MyFooEventArgs, etc . .) public class EventArgs<T> : EventArgs { public EventArgs(T value) { m_value = value; } private T m_value; public T Value { get { return m_value; } } } 回答1: What you are describing are essentially tuples, grouped values

Why to not use a custom class instead of inheriting the EventArgs class

六眼飞鱼酱① 提交于 2019-11-28 10:45:24
I'm wondering why should I use a class that inherits from the EventArgs class instead of using a custom class that will do the same job for me when passing event data? Deanna You don't have to inherit from EventArgs , but it allows people using your classes to use and handle generic *Handler(object sender, EventArgs e) declarations. If you don't inherit from EventArgs , then they have to use explicitly typed *Handler(object sender, YairsFakeEventArgs e) The same goes for just using custom delegates but they are a lot more explicitly different. Because your event-args class will be compatible

How do I make an eventhandler run asynchronously?

拟墨画扇 提交于 2019-11-27 17:36:45
I am writing a Visual C# program that executes a continuous loop of operations on a secondary thread. Occasionally when that thread finishes a task I want it to trigger an eventhandler. My program does that but the when the event handler is triggered, the secondary thread waits until the event handler is finished before continuing the thread. How do I make it continue? Here is the way I currently have it structured... class TestClass { private Thread SecondaryThread; public event EventHandler OperationFinished; public void StartMethod() { ... SecondaryThread.Start(); //start the secondary

Does .NET have a built-in EventArgs<T>?

对着背影说爱祢 提交于 2019-11-27 04:27:13
I am getting ready to create a generic EventArgs class for event args that carry a single argument: public class EventArg<T> : EventArgs { // Property variable private readonly T p_EventData; // Constructor public EventArg(T data) { p_EventData = data; } // Property for EventArgs argument public T Data { get { return p_EventData; } } } Before I do that, does C# have the same feature built in to the language? I seem to recall coming across something like that when C# 2.0 came out, but now I can't find it. Or to put it another way, do I have to create my own generic EventArgs class, or does C#

MVVM Passing EventArgs As Command Parameter

依然范特西╮ 提交于 2019-11-26 06:25:22
I'm using Microsoft Expression Blend 4 I have a Browser .., [ XAML ] ConnectionView " Empty Code Behind " <WebBrowser local:AttachedProperties.BrowserSource="{Binding Source}"> <i:Interaction.Triggers> <i:EventTrigger> <i:InvokeCommandAction Command="{Binding LoadedEvent}"/> </i:EventTrigger> <i:EventTrigger EventName="Navigated"> <i:InvokeCommandAction Command="{Binding NavigatedEvent}" CommandParameter="??????"/> </i:EventTrigger> </i:Interaction.Triggers> </WebBrowser> [ C# ] AttachedProperties class public static class AttachedProperties { public static readonly DependencyProperty

MVVM Passing EventArgs As Command Parameter

五迷三道 提交于 2019-11-26 01:57:07
问题 I\'m using Microsoft Expression Blend 4 I have a Browser .., [ XAML ] ConnectionView \" Empty Code Behind \" <WebBrowser local:AttachedProperties.BrowserSource=\"{Binding Source}\"> <i:Interaction.Triggers> <i:EventTrigger> <i:InvokeCommandAction Command=\"{Binding LoadedEvent}\"/> </i:EventTrigger> <i:EventTrigger EventName=\"Navigated\"> <i:InvokeCommandAction Command=\"{Binding NavigatedEvent}\" CommandParameter=\"??????\"/> </i:EventTrigger> </i:Interaction.Triggers> </WebBrowser> [ C# ]