Exemplo n.º 1
0
        /// <summary>
        /// Creates a new sampler. The sampler has been disegned to support a simple plugin
        /// architecture. With this approach it is more flexible than ever.
        /// </summary>
        public DsSampler(Control ctrl)
        {
            // State
            frameServerIsRunnig = false;
            BMPreqWhileEmpty    = false;
            mediaOnline         = false;
            request             = false;
            mQueue    = ctrl;
            providers = new List <ISampleProvider>();
            stats     = new SamplerStats();

            // Loader
            List <string> ass = new List <string>();

            foreach (string f in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, @"pr*.dll"))
            {
                string aname = f.Substring(f.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                aname = aname.Substring(0, aname.Length - 4);
                ass.Add(aname);
            }

            foreach (string assemblyName in ass)
            {
                try
                {
                    Assembly assembly = AppDomain.CurrentDomain.Load(assemblyName);
                    foreach (Type t in assembly.GetTypes())
                    {
                        foreach (Type it in t.GetInterfaces())
                        {
                            if (it.Equals(typeof(ISampleProvider)))
                            {
                                try
                                {
                                    providers.Add((ISampleProvider)Activator.CreateInstance(t));
                                    break;                                     // The current class is done
                                }
                                catch (MissingMethodException e)
                                {
                                    Console.WriteLine(e.Message);
                                    continue;
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error loading from '" + assemblyName + "': " + e.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            // Updates stats every 100 ms
            SamplerStats s = sampler.Statistics;

            if (s != null)
            {
                numFrames.Text   = s.NumFrames.ToString();
                numRequests.Text = s.NumRequests.ToString();
                numCopies.Text   = s.NumCopies.ToString();
                response.Text    = s.CurrentResponse.ToString("G3") + " ms";
                fps.Text         = s.CurrentFps.ToString("G3");
                avgFps.Text      = s.AvgFps.ToString("G3");
                avgResponse.Text = s.AvgResponse.ToString("G3") + " ms";
                if (s.FrameServerMode)
                {
                    skipFrames.Text = s.SkippedFrames.ToString();
                }
                else
                {
                    skipFrames.Text = "-";
                }
            }
        }