473,503 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determinig if a handler exists from code

Hi all,

Does anyone a way to determine if a handler has been assigned to a delegate,
at runtime? I'm converting some C# code and it tests whether or not the
handler has been assigned. Unfortuntely, VB doesn't support the technique.

Thanks,

Doug
Nov 21 '05 #1
3 1753
* "Doug" <dl***@panthersys.com> scripsit:
Does anyone a way to determine if a handler has been assigned to a delegate,
at runtime? I'm converting some C# code and it tests whether or not the
handler has been assigned. Unfortuntely, VB doesn't support the technique.


You don't need to test that in VB. Simply use 'RaiseEvent'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Thanks for the quick response Herfried,

What I was looking for was a VB equivalent of this C# snippet. VB does
not allow testing the delegate for a handler. It assumes you want to
raise the event.

In hindsight, all it seems to do is not raise the event if no handler is
present. May not be worth the effort...

C#-------
public event QueryShowTheDragCursorEventHandler
QueryShowTheDragCursor;

protected virtual void
OnQueryShowTheDragCursor(QueryShowTheDragCursorEve ntArgs e)
{
//If handler present then raise the event
if(QueryShowTheDragCursor != null)
QueryShowTheDragCursor(this, e);

}

VB-----
Protected Overridable Sub OnQueryShowTheDragCursor(ByVal e As
QueryShowTheDragCursorEventArgs)
If (Not QueryShowTheDragCursor Is Nothing) Then
RaiseEvent QueryShowTheDragCursor(Me, e)
End If
End Sub
Thanks for your time,

Doug

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3
* Doug <an********@developersdex.com> scripsit:
What I was looking for was a VB equivalent of this C# snippet. VB does
not allow testing the delegate for a handler. It assumes you want to
raise the event.

In hindsight, all it seems to do is not raise the event if no handler is
present. May not be worth the effort...
If (Not QueryShowTheDragCursor Is Nothing) Then
RaiseEvent QueryShowTheDragCursor(Me, e)


The 'If...Then...' is not required.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7886
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
4
4437
by: Mark Mikulec | last post by:
Hi there, I wonder if anyone can shed some light on a very frustrating problem. I'm running a debian linux 3.0 "woody" server, nothing special, with the latest version of postres that apt-get...
1
4996
by: malcolm | last post by:
Is there a way to test to see if an event handler hasn't already been added to an event handler listener object? This is what I am doing now as a hack: dataView.ListChanged -= new...
0
1882
by: Anonieko Ramos | last post by:
Answer. Use IHttpHandler. thanks Ro ry for coming up with this code. It processes css file to add variables. neat idea using System; using System.IO; using System.Text; using...
10
3857
by: Wylbur via DotNetMonster.com | last post by:
Hello to all of you geniuses, I'm having a problem trying to get an Init handler to fire for a Placeholder control at the initialization phase. I’ve posted this problem to 3 other ASP.NET...
2
1154
by: Ken Kast | last post by:
What I'm trying to do is find a way to determine at run time if a particular event handler in a UserControl has been defined. Here's a snippet of code: Public Event Button_Click As EventHandler...
7
1817
by: Andrus | last post by:
I noticed that DataGridView CellValidated() and other event handler first parameter is object: Grid.CellValidated+=new DataGridViewCellEventHandler(Grid_CellValidated); .... void...
11
7294
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
7
3141
by: howardk | last post by:
I'm writing some code that loads a number of images, using the standard mechanism of assigning a src url to a newly constructed Image object, thus invoking the image-load operation. On a successful...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.