|
-
Feb 20th, 2009, 10:16 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Translate from C# to VB
I think there should be a seperate area for this kind of questions. 
I'm trying to get the hang of WCF as you probably know from my other posts around here. I found a simple example of WCF callbacks, and I'm trying to understand it by reproducing it. As usual though, the sample is in C#, and although I'm starting to get better at it, I still don't get it all the time.
So here's another piece of C#.... could anyone explain or translate it (will serve as explanation enough I hope) for me?
Code:
public void AddMessage(string message)
{
subscribers.ForEach(delegate(IMessageCallback callback)
{
if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
callback.OnMessageAdded(message, DateTime.Now);
}
else
{
subscribers.Remove(callback);
}
});
}
-
Feb 20th, 2009, 10:39 AM
#2
Thread Starter
Hyperactive Member
Re: Translate from C# to VB
I think I got it..... is this correct?
Code:
Public Sub AddMessage(message As String)
For Each callback As IMessageCallback In subscribers
If DirectCast(callback, ICommunicationsObject).State = CommunicationState.Opened Then
callback.OnMessageAdded(message, DateTime.Now)
Else
subscribers.Remove(callback)
End If
Next
End Sub
-
Feb 20th, 2009, 12:44 PM
#3
Re: Translate from C# to VB
in short it looks like it's looping through a list of potential delegates, if the state is opened, the message gets sent through... if not, then it is removed from the collection.
-tg
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
|
Click Here to Expand Forum to Full Width
|