-
Handling events in VB.NET vs C#
Hi all!
I've been trying to figure out how to do the stuff below in C#. That is,
declare an event with an arbitrary parameter-list, raise it, and, in a client,
declare a variable WithEvents, and then consume the event. Actually, it's
the parameter-list part that's important (specifically to be able to keep
the arbitrary parameter-list).
In component(CSIEFil):
----------------------
Declare:
Public Event SIEImportProgress(ByRef Message As String)
Raise:
RaiseEvent SIEImportProgress("Some message")
In client:
----------
Declare:
Private WithEvents SIEFil As CSIEFil
Consume:
Private Sub SIEFil_SIEImportProgress(ByRef Message As String) Handles SIEFil.SIEImportProgress
TIA!
/Martin
-
Re: Handling events in VB.NET vs C#
Martin,
It should go something like this:
In component(CSIEFil):
public delegate void SIEImportProgressHandle(string Message);
Declare:
public event SIEImportProgressHandler SIEImportProgress;
//Raise:
SIEImportProgress("Some message");
//In client:
----------
Declare:
Private CSIEFil SIEFil;
SIEFil.SIEImportProgress+= new SIEImportProgressHandler (SIEFil_SIEImportProgress);
//Consume:
Private void SIEFil_SIEImportProgress(string strMessage)
{
//Put code here
}
Bruce
"martin rydman" <martin@aprire.se> wrote:
>
>Hi all!
>
>I've been trying to figure out how to do the stuff below in C#. That is,
>declare an event with an arbitrary parameter-list, raise it, and, in a client,
>declare a variable WithEvents, and then consume the event. Actually, it's
>the parameter-list part that's important (specifically to be able to keep
>the arbitrary parameter-list).
>
>
>In component(CSIEFil):
>----------------------
>Declare:
>Public Event SIEImportProgress(ByRef Message As String)
>
>Raise:
>RaiseEvent SIEImportProgress("Some message")
>
>
>In client:
>----------
>Declare:
>Private WithEvents SIEFil As CSIEFil
>
>Consume:
>Private Sub SIEFil_SIEImportProgress(ByRef Message As String) Handles SIEFil.SIEImportProgress
>
>
>TIA!
>
>/Martin
-
Re: Handling events in VB.NET vs C#
Hi Bruce!
Thanks!
/M
"Bruce" <BruceHaslam@Cox.net> wrote:
>
>Martin,
>It should go something like this:
>
>In component(CSIEFil):
>public delegate void SIEImportProgressHandle(string Message);
>
>Declare:
>public event SIEImportProgressHandler SIEImportProgress;
>
>
>//Raise:
>SIEImportProgress("Some message");
>
>
>//In client:
>----------
>Declare:
>Private CSIEFil SIEFil;
>SIEFil.SIEImportProgress+= new SIEImportProgressHandler (SIEFil_SIEImportProgress);
>
>//Consume:
>Private void SIEFil_SIEImportProgress(string strMessage)
>{
> //Put code here
>}
>
>Bruce
>
>
>"martin rydman" <martin@aprire.se> wrote:
>>
>>Hi all!
>>
>>I've been trying to figure out how to do the stuff below in C#. That is,
>>declare an event with an arbitrary parameter-list, raise it, and, in a
client,
>>declare a variable WithEvents, and then consume the event. Actually, it's
>>the parameter-list part that's important (specifically to be able to keep
>>the arbitrary parameter-list).
>>
>>
>>In component(CSIEFil):
>>----------------------
>>Declare:
>>Public Event SIEImportProgress(ByRef Message As String)
>>
>>Raise:
>>RaiseEvent SIEImportProgress("Some message")
>>
>>
>>In client:
>>----------
>>Declare:
>>Private WithEvents SIEFil As CSIEFil
>>
>>Consume:
>>Private Sub SIEFil_SIEImportProgress(ByRef Message As String) Handles SIEFil.SIEImportProgress
>>
>>
>>TIA!
>>
>>/Martin
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks