473,231 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

delegate and event definition problem with compiler warnings

Hi
Im using vs2008 c# 3.0 and am going through some other person(s) code
to clean up compiler warnings that are bieng produced.

I have this code (at bottom)
where a delegate/event is defined

and it builds ok with no errors but im trying to get rid of the
compiler warnings. The warning in this case is

Warning 35 The event
'TestCLassA.MainContainer.BillEventRedrawComplete' is never used
You can see from the code it is used but in a different class, not
seen at build time.

Im wondering if there is a way to make the warning go away, can i
intialise it, in some throw away fassion just to remove the warning.
If this was a simple car like an int thats what i would do.

I dont want to disbale warnings in the compiler, can anyone suggest
what i can do to remove this warning on build of this code

thanks for any help

Peted
namespace TestClassA
{

public delegate void BillEventRedrawComplete();

[Guid("A10D9EF1-508C-40b9-8B17-69E14CC08E3A")]
[ProgId("EMIS.PCS.BillingModule.MainContainer")]
[ClassInterface(ClassInterfaceType.None)]

public class MainContainer : System.Windows.Forms.UserControl
{
#region Custom Events

public static event BillEventRedrawComplete
BillEventRedrawComplete;
#endregion Custom Events

/... etc etc etc
then in another class,


namespace TestClassB
{
public class BillingEvent : UserControl, IBillingModule,
IBillingEvent
{

private void BillingEvent_Load(object sender, EventArgs e)
{
MainContainer.BillEventRedrawComplete += new
BillEventRedrawComplete(MainContainer_BillEventRed rawComplete);
}

etc etc etc


Jun 27 '08 #1
3 1717
On Jun 17, 10:48 am, Peted wrote:
Im using vs2008 c# 3.0 and am going through some other person(s) code
to clean up compiler warnings that are bieng produced.

I have this code (at bottom)

where a delegate/event is defined

and it builds ok with no errors but im trying to get rid of the
compiler warnings. The warning in this case is

Warning 35 The event
'TestCLassA.MainContainer.BillEventRedrawComplete' is never used
That seems very odd. Could you produce a short but complete program
which shows it? Then we can report it to the compiler team.

Perhaps it's not "used" in terms of never being fired from within the
class - in which case I question its usefulness.

In terms of removing the warning, I'd use a pair of #pragma directives
around just that line of code - it makes it obvious what you're doing,
compared with using the event for no reason elsewhere.

As I say though, I can't see that it's currently doing anything useful
- just being able to subscribe to an event isn't really useful when it
never gets fired.

Jon
Jun 27 '08 #2
But nothing will ever *raise* that event; if you add some code that
invokes the event the message should disappear.

For info, you need to be careful with instances (such as BillingEvent)
subscribing to static events (such as BillEventRedrawComplete); it is
very easy for the event to keep all your instances alive by mistake.

Marc
Jun 27 '08 #3
>
Perhaps it's not "used" in terms of never being fired from within the
class - in which case I question its usefulness.
thats what im thinking
>
In terms of removing the warning, I'd use a pair of #pragma directives
around just that line of code - it makes it obvious what you're doing,
compared with using the event for no reason elsewhere.
i think i will try this

thanks

Peted
Jun 27 '08 #4

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

Similar topics

6
by: ALI-R | last post by:
What is the difference between implementing an Event using a Deligate or an Event Handler?,look at below 1)this.button1.Click += new System.EventHandler(this.button1_Click); ..................
5
by: Mats Larsson | last post by:
Hi, I have an example in C# for testing if a handler has been assigned to the delegate, I would like to do the same in VB.NET but I don't understand how. The C# code is copied from the Northwind...
5
by: han zhiyang | last post by:
Hi. I tried to design a custom web control which can flexibly and dynamicly let the control user ,for example the web page developer, customize its layout codes.This control derives from...
4
by: ^MisterJingo^ | last post by:
Hi all, I've been trying to get my head around delegates. The book i'm using had a single example, not much explaination, and didn't show how to set up a delegate and pass variables in and out...
2
by: zamir.khan | last post by:
Hello all, New to the groups, sorry if this the wrong forum/etiquette. I am coding a c++ application that requires the use of a timer-triggered event handler. I decided to use the timer provided...
7
by: Ant | last post by:
Hello, Very simple question but one I need clarified. Which part of the statement below is considered the 'delegate'? Is it the 'new System.EventHandler' or the btnAccept_Click? or is it...
6
by: Bart Burkhardt | last post by:
Hi, I could use some help in setting a C# callback function that an external unmanaged dll will call on a event. Using a delegate and use the external callback set function doesn't work. The...
11
by: matsi.inc | last post by:
I am looking to make something like a delegate that i can use in my projects but am having a hard time getting started. The behavior I am most interested in is how a delegate changes it's Invoke...
6
by: damiensawyer | last post by:
Hi, Can someone please explain to me something about delegates? My understanding is as follows. A delegate is basically an object that can hold a reference to a "method" somewhere. That is,...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.