Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2003, 03:58 PM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB.Net delegates called in C#?

I have a class that was written in VB.Net that I need to call in C#. This isn't the problem. The problem is that I have a delegate like so:

Code:
#Region "DELEGATES"
    Public onCURRENT_STATUS As CURRENT_STATUS
    Public Delegate Sub CURRENT_STATUS(ByVal strMessage As String, ByVal CLS As clsLD_HISTORY)
#End Region
Then I have a sub that calls the onCURRENT_STATUS like so

Code:
    public sub TEST_DELEGATE
          'SEND MESSAGE - STARTING 
        If Not Me.onCURRENT_STATUS Is Nothing Then
            Me.onCURRENT_STATUS.Invoke("Starting Process...", Me)
        End If
    end sub
In VB.Net I would call it like so :

Code:
 dim myCLASS as new TEST_CLASS()

 Me.myCLASS.onCURRENT_STATUS = AddressOf Me.DISPLAY_STATUS
Where Me.DISPLAY_STATUS is a sub or function in the calling class that matches the original delegates signature.

In C# I can't figure out how to do the AddressOf? Is it possible?

Please need help ASAP.

Thank you,

Christopher P. Cooper


It's important for us to explain to our nation that life is important. It's not only life of babies, but it's life of children living in, you know, the dark dungeons of the Internet."— George W. Bush - Arlington Heights, Ill., Oct. 24, 2000
__________________
Vote Kerry/Edwards 2004

It\'s important for us to explain to our nation that life is important. It\'s not only life of babies, but it\'s life of children living in, you know, the dark dungeons of the Internet.\"— George W. Bush - Arlington Heights, Ill., Oct. 24, 2000
 
Old November 6th, 2003, 04:36 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think you want something like this:

Me.myCLASS.onCURRENT_STATUS += new System.EventHandler(Me.DISPLAY_STATUS);

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 6th, 2003, 05:13 PM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thought so, the problem is that the signature doesn't match the System.EventHandler. So is there any other way? Can I create my own event handler?


It's important for us to explain to our nation that life is important. It's not only life of babies, but it's life of children living in, you know, the dark dungeons of the Internet."— George W. Bush - Arlington Heights, Ill., Oct. 24, 2000
 
Old November 6th, 2003, 05:41 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Either you need to match up your signatures, or you could make a dud handler with a matching signature, then call your other method from it.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with delegates mike_remember ASP.NET 1.0 and 1.1 Professional 2 November 7th, 2006 12:33 AM
DTS Fails when called from VB levinll SQL Server DTS 1 November 10th, 2005 02:05 PM
Delegates in .NET jkahin C# 2 August 8th, 2005 02:31 PM
I still Don't get Delegates p_nut33 Pro VB.NET 2002/2003 2 April 26th, 2004 01:50 PM
Delegates Ibn_Aziz C# 0 February 3rd, 2004 05:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.