Hi, I'm looking for some exemplary tests for programmer candidates, these test should be language unrelated. Does anybody know where I can find it? Thank you in advance!
seconds87
Posts
-
Exemplary tests for programmer candidates -
Leasing and sponsoring .netI'd like to thank you for help, I found the solution for first problem... I didn't know that:
current lease time = MAX(lease time - expired time,renew on call time)
source: http://msdn.microsoft.com/en-us/magazine/cc300474.aspx 2. You wrote: "and the actual object exists and is even outputting text onto the Server's console" yes, I know but I'd like to have a reference to this object (I want to communicate with it), this remote object is working fine (object is created and managed by client) but everything is working on "background". I have got a primitive way to comunicate with every object by static class members but it's not exactly what I want to. -
Leasing and sponsoring .netHi, Nowaday I'm working on .net remoting and I've got some problem with leasing. there is my code:
//RemoteObject
public class X : MarshalByRefObject
{
public int x;
public X()
{
Console.WriteLine("some X object is done...");
}
public void PrintAboutMe()
{
ILease itfILease = (ILease)RemotingServices.GetLifetimeService(this);
Console.WriteLine("CurrentState: " + itfILease.CurrentState);
Console.WriteLine("InitialLeaseTime: " + itfILease.InitialLeaseTime.Minutes +
":" + itfILease.InitialLeaseTime.Seconds);
Console.WriteLine("CurrentLeaseTime: " + itfILease.CurrentLeaseTime.Minutes +
":" + itfILease.CurrentLeaseTime.Seconds);
Console.WriteLine("RenewOnCallTime: " + itfILease.RenewOnCallTime.Minutes +
":" + itfILease.RenewOnCallTime.Seconds);
Console.WriteLine("SponsorShipTime: " + itfILease.SponsorshipTimeout.Minutes +
":" + itfILease.SponsorshipTimeout.Seconds);
Console.WriteLine("x = " + x);
}
public override object InitializeLifetimeService()
{
ILease itfLease = (ILease)base.InitializeLifetimeService();
if (itfLease.CurrentState == LeaseState.Initial)
{
itfLease.InitialLeaseTime = TimeSpan.FromSeconds(10);
itfLease.RenewOnCallTime = TimeSpan.FromSeconds(6);
itfLease.SponsorshipTimeout = TimeSpan.FromSeconds(6);
}
// return null;
return itfLease;
}
public void IncrementX()
{
x++;
Console.WriteLine("\nIncrement x member ...\n");
}
public void ChangeLifetime()
{
ILease itfILease = (ILease)RemotingServices.GetLifetimeService(this);
itfILease.Renew(TimeSpan.FromSeconds(20));
}
}
//SponsorObjectCode
public class MySponsor : MarshalByRefObject, ISponsor
{
public TimeSpan Renewal(ILease il)
{
Console.WriteLine("I've been asked to renew the lease.");
return TimeSpan.FromSeconds(20);
}
}//ClientCode:
public static void Main(string[] args)
{
HttpChannel c = new HttpChannel(null,
new BinaryClientFormatterSinkProvider(),
null);
ChannelServices.RegisterCh