Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2006

Tip: Looking for answers? Try searching our database.

How to test if a delegate or event is empty

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RFOG - 13 Oct 2006 12:31 GMT
In C# is very easy:

if(myDelegate==null)
   //Install it.

but in C++/CLI that does not work:

if(myDelegate==nullptr)
   //Install it.

gives:

Error C3918:usage requires 'member' to be a data member

But myDelegate has operator == overloaded. I don't understand why it fails.
If I try some like this:

myDelegate->GetInvocationList()->Length==0

I get same error.

And other variations.
Signature

Visita mi blog: http://rfog.blogsome.com
Libros, ciencia ficción y programación
========================================
La amistad es más difícil y más rara que el amor. Por eso, hay que salvarla
como sea.
 -- Alberto Moravia. (1907-1990) Escritor italiano.

Ben Voigt - 07 Nov 2006 20:55 GMT
> In C# is very easy:
>
[quoted text clipped - 9 lines]
>
> Error C3918:usage requires 'member' to be a data member

Use a custom event, like this:

private:

//! \brief MulticastDelegate chain of event handlers for the \ref Closed
event.

System::EventHandler^ CloseHandlers;

public:

virtual event System::EventHandler^ Closed

{

void add( System::EventHandler^ handler )

{

CloseHandlers += handler;

}

void remove( System::EventHandler^ handler )

{

CloseHandlers += handler;

}

}

> But myDelegate has operator == overloaded. I don't understand why it
> fails.
[quoted text clipped - 5 lines]
>
> And other variations.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.