translation from C# to VC++ .NET

  • Thread starter Thread starter José Achig
  • Start date Start date
J

José Achig

Hello

I want to change this code example wrote in C# to VC++ .NET, please give me
a translation

namespace MyNamespace
{
public class MyObject : MarshalByRefObject{
public override Object InitializeLifetimeService()
{
// This lease never expires.
return null;
// Use following code to define the exact lease time.
ILease lease = (ILease)base.InitializeLifetimeService();

if (lease.CurrentState == LeaseState.Initial)
{
lease.InitialLeaseTime =
TimeSpan.FromSeconds(5);
lease.SponsorshipTimeout =
TimeSpan.FromSeconds(0);
lease.RenewOnCallTime = TimeSpan.FromSeconds(5);
}
return lease;
}
}
}

Thanks in advance!!!
 
Something like :-

namespace MyNamespace
{
public __gc class MyObject : public MarshalByRefObject
{
public:
Object* InitializeLifetimeService()
{
// This lease never expires.
return 0;

// Use following code to define the exact lease time.
ILease* lease = static_cast<ILease*>(
MarshalByRefObject::InitializeLifetimeService());

if (lease->CurrentState == LeaseState::Initial)
{
lease->InitialLeaseTime = TimeSpan::FromSeconds(5);
lease->SponsorshipTimeout = TimeSpan::FromSeconds(0);
lease->RenewOnCallTime = TimeSpan::FromSeconds(5);
}
return lease;
}

};
}

BTW, since you return at the beginning of the function the rest of the code
never gets executed.
 
Back
Top