using System.Collections.Generic;
using System.Threading.Tasks;
namespace Rabobank.Training
public static void Main()
Console.WriteLine("Main Thread");
Console.WriteLine("Sleep for 1 minute");
TimeSpan tim= new TimeSpan(0,0,1);
Console.WriteLine("Thread is sleeping 1 seconds");
var asyncTask=Task.Run(()=>{Console.WriteLine("Thread Asyn",Task.CurrentId,Thread.CurrentThread.ManagedThreadId);
var syncTask=new Task<long>(()=>{Console.WriteLine("Thread syn",Task.CurrentId,Thread.CurrentThread.ManagedThreadId);
syncTask.RunSynchronously();
Console.WriteLine("Task sync{0} returned{1:No}",syncTask.Id,syncTask.Result);
Console.WriteLine("Task async {0} returned{1:No}",asyncTask.Id,asyncTask.Result);
Console.WriteLine("Main End");
FundOfMandates fom= new FundOfMandates();
fom.Name="Rabobank Core Aandelen Fonds NT";
fom.LiquidityAllocation=0.1m;
IList<Mandate> list1= Mandate.ListMan();
fom.listMan=Mandate.ListMan();
Console.WriteLine(String.Format("\nMandates-id LiquidtyAllocation MandateName \n_________________________________________________________________"));
foreach(Mandate man in list1)
Console.WriteLine(String.Format("{0} {1} {2}",man.Id, man.Allocation,man.Name));
IList<PositionVM> list2 =CalculatedMandates(fom,45678);
Instrument str= new Instrument();
int Total=str.Sector1+str.Sector2+str.Sector3+str.Sector4;
bool result =str.IntegerExtension();
Console.WriteLine("Extension method:" +result );
static async void Asynmethod()
Console.WriteLine("async Starts");
var result= await Mymethod();
Console.WriteLine("async End");
public static async Task<int> Mymethod()
Console.WriteLine("async runs"+i.ToString()+"..");
private static void Work()
Console.WriteLine("Sleep for 1 minute");
public static IList<PositionVM> CalculatedMandates(FundOfMandates fom,int Postion )
string strcode= fom.Code;
IList<Mandate> list1=fom.listMan;
if(fom.LiquidityAllocation>0)
list1.Add(new Mandate{Name="Liquidity",Allocation=fom.LiquidityAllocation});
IList<MandateVM> list4= new List<MandateVM>();
IList<PositionVM> listPos= new List<PositionVM>();
Console.WriteLine(String.Format("\nCode Name Value \n_________________________________________________________________"));
listPos=new List<PositionVM>{
new PositionVM{Code=strcode, Value=intPos}};
foreach(PositionVM PosVm in listPos)
Console.WriteLine(String.Format("{0} {1} {2}",PosVm.Code, fom.Name,PosVm.Value));
Console.WriteLine(String.Format("\nName Allocation Value \n_________________________________________________________________"));
for (var i = 0; i < list1.Count; i++) {
Decimal Lvalue = Math.Round((intPos*(list1[i].Allocation/100)));
if(list1[i].Allocation!=0.1m)
if(list1[i].Allocation==0.1m)
list3=new List <MandateVM> {new MandateVM{Name=list1[i].Name,Allocation= list1[i].Allocation,Value=Lvalue}};
foreach(MandateVM PosVm in list3)
Console.WriteLine(String.Format("{0} {1} {2}",PosVm.Name, PosVm.Allocation,PosVm.Value));
foreach(PositionVM PosVm in listPos)
Console.WriteLine(String.Format("\n{0} {1} €{2} ",PosVm.Code, fom.Name,PosVm.Value/1000));
for (var i = 0; i < list1.Count; i++) {
Decimal Lvalue = Math.Round((intPos*(list1[i].Allocation/100)));
if(list1[i].Allocation!=0.1m)
if(list1[i].Allocation==0.1m)
list3=new List <MandateVM> {new MandateVM{Name=list1[i].Name,Allocation= list1[i].Allocation,Value=Lvalue}};
foreach(MandateVM PosVm in list3){
if(PosVm.Allocation!=0.1m)
PosVm.Value=PosVm.Value/1000;
Console.WriteLine(String.Format("{0} {1} € {2}",PosVm.Name, PosVm.Allocation,PosVm.Value));
public class FundOfMandates
public Decimal LiquidityAllocation;
private IList<Mandate> _listMan ;
public IList <Mandate> listMan
public void GetFundofMandates()
Console.WriteLine(String.Format("\nCode Name LiquidityAllocation \n_________________________________________________________________"));
Console.WriteLine(String.Format("{0} {1} {2}",Code, Name, LiquidityAllocation+"(as percentage, so 0.1)"));
private Decimal _allocation;
public Decimal Allocation
get {return _allocation;}
set {_allocation= value;}
public static IList<Mandate> ListMan()
var list= new List<Mandate>{
new Mandate{Id="NL0000292332-01", Allocation=33.6m, Name="Amundi Busniess Sector Fund"},
new Mandate{Id="NL0000292332-02", Allocation=32.4m, Name="Amundi Financial Sector Fund"},
new Mandate{Id="NL0000292332-03", Allocation=33.9m, Name="Amundi Commodities Sector Fund"},
private IList<MandateVM> _listManVM ;
public IList <MandateVM> listManVM
private Decimal _allocation;
public Decimal Allocation
get {return _allocation;}
set {_allocation= value;}
public static class ExtMetClass
public static bool IntegerExtension(this Instrument totalSector )
int total=totalSector.Sector1+totalSector.Sector2+totalSector.Sector3+totalSector.Sector4;