473,326 Members | 2,337 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,326 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 1719
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,...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.