Beispiel #1
0
        public static void Readfromfile()
        {
            System.Configuration.AppSettingsReader r = new System.Configuration.AppSettingsReader();
            string path = (string)r.GetValue("simulationsettings",typeof(String));

            var ser = new XmlSerializer(typeof(Sim));

            using (var ms = new StreamReader(path))
            {
                sim = (Sim)ser.Deserialize(ms);
                ms.Close();
            }
        }
 //public void Check(string msg)
 //{
 //    //System.Configuration.AppSettingsReader r = new System.Configuration.AppSettingsReader();
 //    //string path = (string)r.GetValue("GeneralLog", typeof(String));
 //    //using (StreamWriter outfile = File.AppendText(path))
 //    //{
 //    //    outfile.WriteLine("Check was called with : " + msg);
 //    //    outfile.Close();
 //    //}
 //}
 public void PerformanceSimulation()
 {
     SimulationDL.Readfromfile();//this is enough for simulation,
     this.sim = SimulationDL.sim;
     StackTrace stackTrace = new StackTrace();
     MethodBase methodBase = stackTrace.GetFrame(1).GetMethod();
     methodName = methodBase.Name;
     var query = from p in sim.methodSimulationMap
                 where p.methodname == methodName
                 select p;
     sa = query.ToList()[0];
     if (sa.throwException)
     {
         throw new Exception();
     }
     System.Threading.Thread.Sleep(sa.sleep * 1000); //convert seconds to milliseconds
     if (sa.consumeheap)
     {
         keepConsuming = true;
         Runconsumeheap(sa.consumeheapfactor);
     }
     if (sa.consumecpu)
     {
         workerThread.Start();
     }
 }
        void watcher_Changed(object sender, FileSystemEventArgs e)
        {
            SimulationDL.Readfromfile();//this is enough for simulation,
            this.sim = SimulationDL.sim;
            if (methodName != null)
            {
                var query = from p in sim.methodSimulationMap
                            where p.methodname == methodName
                            select p;

                sa = query.ToList()[0];
                keepConsuming = sa.consumeheap;
            }
        }
 public Simulator(Sim sim)
     : base()
 {
     this.sim = sim;
 }