Func<double, Func<double, double>> areaOfCircle = factor => r => { Console.WriteLine("area factor is {0}", factor); return (double)(factor * Math.Pow(r, 2)); }; Func<double, Func<double, double>> diameterOfCircle = factor => r => { Console.WriteLine("diameter factor is {0}", factor); return (double)(2 * factor * r); }; var funcList = new List<Func<double, double>>() { diameterOfCircle(Math.PI), areaOfCircle(Math.PI), diameterOfCircle(3), areaOfCircle(3.14), }; foreach(var iNeed in funcList) { //Console.WriteLine(iNeed(5)); Console.WriteLine(iNeed(10)); }
#!/bin/bash MIN_ACT=200 echo Looking for running qBitorrent. Please wait... TORR_PID=$( ps aux | grep '[q]bittorrent' | awk '{ print $2 }' ) if [ -z "$TORR_PID" ]; then echo qBittorrent not found. else echo Collecting traffic infomation. Please wait... ACTIVITY=$( collectl -c1 -i5 -sn | awk 'NF==4 { print $1 }' ) if [ $ACTIVITY -lt $MIN_ACT ]; then echo Traffic is low. Killing qBittorrent PID:$TORR_PID. Please wait... kill -s SIGTERM $TORR_PID fi fi echo killqb done.