473,698 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can someone please translate this to VB.Net


public class Broadcaster: MarshalByRefObj ect, IBroadcaster
{

public event General.Message ArrivedHandler MessageArrived;

public void BroadcastMessag e(string msg) {
Console.WriteLi ne("Will broadcast message: {0}", msg);
SafeInvokeEvent (msg);
}

private void SafeInvokeEvent (String msg) {
// call the delegates manually to remove them if they aren't
// active anymore.

if (MessageArrived == null) {
Console.WriteLi ne("No listeners");
} else {
Console.WriteLi ne("Number of Listeners:
{0}",MessageArr ived.GetInvocat ionList().Lengt h);
MessageArrivedH andler mah=null;

foreach (Delegate del in MessageArrived. GetInvocationLi st()) {
try {
mah = (MessageArrived Handler) del;
mah(msg);
} catch (Exception e) {
Console.WriteLi ne("Exception occured, will remove Delegate");
MessageArrived -= mah;
}
}
}
}

public override object InitializeLifet imeService() {
// this object has to live "forever"
return null;
}
}
class ServerStartup
{
static void Main(string[] args)
{
String filename = "server.exe.con fig";
RemotingConfigu ration.Configur e(filename);

Console.WriteLi ne ("Server started, press <returnto exit.");
Console.ReadLin e();
}
}
Nov 25 '06 #1
3 2785
http://authors.aspalliance.com/aldot...translate.aspx
"Mike" <jm***@yahoo.co mwrote in message
news:EF******** *************** ***********@mic rosoft.com...
>
public class Broadcaster: MarshalByRefObj ect, IBroadcaster
{

public event General.Message ArrivedHandler MessageArrived;

public void BroadcastMessag e(string msg) {
Console.WriteLi ne("Will broadcast message: {0}", msg);
SafeInvokeEvent (msg);
}

private void SafeInvokeEvent (String msg) {
// call the delegates manually to remove them if they aren't
// active anymore.

if (MessageArrived == null) {
Console.WriteLi ne("No listeners");
} else {
Console.WriteLi ne("Number of Listeners:
{0}",MessageArr ived.GetInvocat ionList().Lengt h);
MessageArrivedH andler mah=null;

foreach (Delegate del in MessageArrived. GetInvocationLi st()) {
try {
mah = (MessageArrived Handler) del;
mah(msg);
} catch (Exception e) {
Console.WriteLi ne("Exception occured, will remove Delegate");
MessageArrived -= mah;
}
}
}
}

public override object InitializeLifet imeService() {
// this object has to live "forever"
return null;
}
}
class ServerStartup
{
static void Main(string[] args)
{
String filename = "server.exe.con fig";
RemotingConfigu ration.Configur e(filename);

Console.WriteLi ne ("Server started, press <returnto exit.");
Console.ReadLin e();
}
}


Nov 25 '06 #2
(via Instant VB - note that there is no IBroadcaster defined in the original
code or the .NET Framework, so you'll have to add the "Implements " tags to
the methods yourself)

Public Class Broadcaster
Inherits MarshalByRefObj ect
Implements IBroadcaster

Public Event MessageArrived As General.Message ArrivedHandler

Public Sub BroadcastMessag e(ByVal msg As String)
Console.WriteLi ne("Will broadcast message: {0}", msg)
SafeInvokeEvent (msg)
End Sub

Private Sub SafeInvokeEvent (ByVal msg As String)
' call the delegates manually to remove them if they aren't
' active anymore.

If MessageArrivedE vent Is Nothing Then
Console.WriteLi ne("No listeners")
Else
Console.WriteLi ne("Number of Listeners:
{0}",MessageArr ivedEvent.GetIn vocationList(). Length)
Dim mah As MessageArrivedH andler=Nothing

For Each del As System.Delegate In MessageArrivedE vent.GetInvocat ionList()
Try
mah = CType(del, MessageArrivedH andler)
mah(msg)
Catch e As Exception
Console.WriteLi ne("Exception occured, will remove Delegate")
RemoveHandler MessageArrived, mah
End Try
Next del
End If
End Sub

Public Overrides Function InitializeLifet imeService() As Object
' this object has to live "forever"
Return Nothing
End Function
End Class
Friend Class ServerStartup
Shared Sub Main(ByVal args As String())
Dim filename As String = "server.exe.con fig"
RemotingConfigu ration.Configur e(filename)

Console.WriteLi ne ("Server started, press <returnto exit.")
Console.ReadLin e()
End Sub
End Class

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"Mike" wrote:
>
public class Broadcaster: MarshalByRefObj ect, IBroadcaster
{

public event General.Message ArrivedHandler MessageArrived;

public void BroadcastMessag e(string msg) {
Console.WriteLi ne("Will broadcast message: {0}", msg);
SafeInvokeEvent (msg);
}

private void SafeInvokeEvent (String msg) {
// call the delegates manually to remove them if they aren't
// active anymore.

if (MessageArrived == null) {
Console.WriteLi ne("No listeners");
} else {
Console.WriteLi ne("Number of Listeners:
{0}",MessageArr ived.GetInvocat ionList().Lengt h);
MessageArrivedH andler mah=null;

foreach (Delegate del in MessageArrived. GetInvocationLi st()) {
try {
mah = (MessageArrived Handler) del;
mah(msg);
} catch (Exception e) {
Console.WriteLi ne("Exception occured, will remove Delegate");
MessageArrived -= mah;
}
}
}
}

public override object InitializeLifet imeService() {
// this object has to live "forever"
return null;
}
}
class ServerStartup
{
static void Main(string[] args)
{
String filename = "server.exe.con fig";
RemotingConfigu ration.Configur e(filename);

Console.WriteLi ne ("Server started, press <returnto exit.");
Console.ReadLin e();
}
}

Nov 26 '06 #3
Thanks David!

"David Anton" <Da********@dis cussions.micros oft.comwrote in message
news:24******** *************** ***********@mic rosoft.com...
(via Instant VB - note that there is no IBroadcaster defined in the
original
code or the .NET Framework, so you'll have to add the "Implements " tags to
the methods yourself)

Public Class Broadcaster
Inherits MarshalByRefObj ect
Implements IBroadcaster

Public Event MessageArrived As General.Message ArrivedHandler

Public Sub BroadcastMessag e(ByVal msg As String)
Console.WriteLi ne("Will broadcast message: {0}", msg)
SafeInvokeEvent (msg)
End Sub

Private Sub SafeInvokeEvent (ByVal msg As String)
' call the delegates manually to remove them if they aren't
' active anymore.

If MessageArrivedE vent Is Nothing Then
Console.WriteLi ne("No listeners")
Else
Console.WriteLi ne("Number of Listeners:
{0}",MessageArr ivedEvent.GetIn vocationList(). Length)
Dim mah As MessageArrivedH andler=Nothing

For Each del As System.Delegate In MessageArrivedE vent.GetInvocat ionList()
Try
mah = CType(del, MessageArrivedH andler)
mah(msg)
Catch e As Exception
Console.WriteLi ne("Exception occured, will remove Delegate")
RemoveHandler MessageArrived, mah
End Try
Next del
End If
End Sub

Public Overrides Function InitializeLifet imeService() As Object
' this object has to live "forever"
Return Nothing
End Function
End Class
Friend Class ServerStartup
Shared Sub Main(ByVal args As String())
Dim filename As String = "server.exe.con fig"
RemotingConfigu ration.Configur e(filename)

Console.WriteLi ne ("Server started, press <returnto exit.")
Console.ReadLin e()
End Sub
End Class

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"Mike" wrote:
>>
public class Broadcaster: MarshalByRefObj ect, IBroadcaster
{

public event General.Message ArrivedHandler MessageArrived;

public void BroadcastMessag e(string msg) {
Console.WriteL ine("Will broadcast message: {0}", msg);
SafeInvokeEven t(msg);
}

private void SafeInvokeEvent (String msg) {
// call the delegates manually to remove them if they aren't
// active anymore.

if (MessageArrived == null) {
Console.WriteL ine("No listeners");
} else {
Console.WriteL ine("Number of Listeners:
{0}",MessageAr rived.GetInvoca tionList().Leng th);
MessageArrived Handler mah=null;

foreach (Delegate del in MessageArrived. GetInvocationLi st()) {
try {
mah = (MessageArrived Handler) del;
mah(msg);
} catch (Exception e) {
Console.WriteL ine("Exception occured, will remove Delegate");
MessageArriv ed -= mah;
}
}
}
}

public override object InitializeLifet imeService() {
// this object has to live "forever"
return null;
}
}
class ServerStartup
{
static void Main(string[] args)
{
String filename = "server.exe.con fig";
RemotingConfig uration.Configu re(filename);

Console.WriteL ine ("Server started, press <returnto exit.");
Console.ReadLi ne();
}
}

Nov 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1980
by: Michael Lauzon | last post by:
A while back, I had a program that I was working on, while taking Java in a Web Design & Development course -- this was back in 1999 -- not having the mindset of a programmer I failed that part of the course misrably. I had to do the following program, but you can see why I failed, I only managed to write to lines of code. I am wondering if there is anyone who can write it to the following criteria, maybe even make it graphical...I am...
7
2332
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None, 'badcharshere') Regards, Bengt Richter
6
2777
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
23
2305
by: Ray | last post by:
Hello! I've been reading about PyPy, but there are some things that I don't understand about it. I hope I can get some enlightenment in this newsgroup :) First, the intro: <excerpt> "The PyPy project aims at producing a flexible and fast Python
8
4562
by: MLH | last post by:
The following SQL returns PRECISELY what I want: SELECT TOP 1 tblCorrespondence.CorrespID, tblOutboundTypes.OTypDescription, tblCorrespondence.OutDate, tblCorrespondence.VehicleJobID, tblCorrespondence.OutType FROM tblOutboundTypes INNER JOIN tblCorrespondence ON tblOutboundTypes.OutType = tblCorrespondence.OutType WHERE (((tblCorrespondence.OutDate) Is Not Null) AND ((tblCorrespondence.VehicleJobID)=3)) ORDER BY...
9
3101
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc. ## All rights reserved. ## NOT FOR SALE. The software is provided "as is" without any warranty. ############################################################################ """ Class...
3
1528
by: raz230 | last post by:
I'm sorry for posting this here- I have to integrate an parcel tracking with Canada Post into one of my applications. The web service they use is made with SAP and is not the usual WSDL type of service I am used to. I cannot just add a web reference to my project and get going. Canada Post provides a sample in Java and C# - and I do not know either.
11
1790
by: Adrian | last post by:
Could someone please translate the code below into C#? Please also tell me the libraries I might need. Many thanks, Adrian. int main() { (GetProcAddress( LoadLibrary( "krnl386.exe" ), "exitkernel" ))();
3
4700
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
0
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7716
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.