CSharpTest.Net
EventHandlerForControl<TEventArgs> Constructor(Control,Delegate)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class > EventHandlerForControl<TEventArgs> Constructor : EventHandlerForControl<TEventArgs> Constructor(Control,Delegate)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified delegate converting it to the expected EventHandler<TEventArgs> delegate type.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal control As Control, _
   ByVal handler As Delegate _
)
C# 
public EventHandlerForControl<TEventArgs>( 
   Control control,
   Delegate handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C#Copy Code
EventHandler<VerifiedReceiptEventArgs> handler;
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
            
_thread.Start();
_form.FormCreated.WaitOne();

handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler(null, args.Reset());
Assert.IsTrue(args.Received);
Assert.IsTrue(args.OnThread);

handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(VerifiedReceiptRedirect));
handler(null, args.Reset());
Assert.IsTrue(args.Received);
Assert.IsTrue(args.OnThread);

_form.BeginInvoke((Action)_form.Close);
_thread.Join();
VB.NETCopy Code
Dim handler As EventHandler(Of VerifiedReceiptEventArgs)
Dim args As New VerifiedReceiptEventArgs()

_thread.Start()
_form.FormCreated.WaitOne()

handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler(Nothing, args.Reset())
Assert.IsTrue(args.Received)
Assert.IsTrue(args.OnThread)

handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(VerifiedReceiptRedirect))
handler(Nothing, args.Reset())
Assert.IsTrue(args.Received)
Assert.IsTrue(args.OnThread)

_form.BeginInvoke(DirectCast(_form.Close, Action))
_thread.Join()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys