public void Run <TFunc1, TFunc2>() where TFunc1 : new() where TFunc2 : new() { int totalInvocations = 0; int statsPeriodInvocations = 0; double totalDurationMillisSum = 0.0; double statsPeriodDurationMillisSum = 0.0; ulong totalInnerIterations = 0; ulong statsPeriodInnerIterations = 0; DateTimeOffset statsPeriodStartTime, startTime; statsPeriodStartTime = startTime = DateTimeOffset.Now; TClass1 classParam1Instance = new TClass1(); Console.WriteLine($"Type of classParam1-Instance: \"{classParam1Instance.GetType().FullName}\"."); TClass2 classParam2Instance = new TClass2(); Console.WriteLine($"Type of classParam2-Instance: \"{classParam2Instance.GetType().FullName}\"."); TFunc1 funcParam1Instance = new TFunc1(); Console.WriteLine($"Type of funcParam1-Instance: \"{funcParam1Instance.GetType().FullName}\"."); TFunc2 funcParam2Instance = new TFunc2(); Console.WriteLine($"Type of funcParam2-Instance: \"{funcParam2Instance.GetType().FullName}\"."); DoInvocations(ref totalInvocations, ref statsPeriodInvocations, ref totalDurationMillisSum, ref statsPeriodDurationMillisSum, ref totalInnerIterations, ref statsPeriodInnerIterations, ref statsPeriodStartTime, startTime); }
public void Start <TFunc1, TFunc2>() where TFunc1 : new() where TFunc2 : new() { const string ThreadName = "Computer Thread"; Console.WriteLine($"Current thread: ManagedThreadId={Thread.CurrentThread.ManagedThreadId}, Name=\"{Thread.CurrentThread.Name}\"."); Console.WriteLine($"Renaming current thread..."); Thread.CurrentThread.Name = ThreadName; int totalInvocations = 0; int statsPeriodInvocations = 0; double totalDurationMillisSum = 0.0; double statsPeriodDurationMillisSum = 0.0; ulong totalInnerIterations = 0; ulong statsPeriodInnerIterations = 0; DateTimeOffset statsPeriodStartTime, startTime; statsPeriodStartTime = startTime = DateTimeOffset.Now; TClass1 classParam1Instance = new TClass1(); Console.WriteLine($"Type of classParam1-Instance: \"{classParam1Instance.GetType().FullName}\"."); TClass2 classParam2Instance = new TClass2(); Console.WriteLine($"Type of classParam2-Instance: \"{classParam2Instance.GetType().FullName}\"."); TFunc1 funcParam1Instance = new TFunc1(); Console.WriteLine($"Type of funcParam1-Instance: \"{funcParam1Instance.GetType().FullName}\"."); TFunc2 funcParam2Instance = new TFunc2(); Console.WriteLine($"Type of funcParam2-Instance: \"{funcParam2Instance.GetType().FullName}\"."); ManualResetEventSlim stopedSignal = _stopedSignal; while (stopedSignal == null) { DoInvocations(ref totalInvocations, ref statsPeriodInvocations, ref totalDurationMillisSum, ref statsPeriodDurationMillisSum, ref totalInnerIterations, ref statsPeriodInnerIterations, ref statsPeriodStartTime, startTime); Thread.Yield(); stopedSignal = _stopedSignal; } stopedSignal.Set(); }
protected override void Init() { this.f1 = this.LoadFunction<TFunc1>("test"); }