Esempio n. 1
0
        public void SpawnAnimationThread(PerFrameCallback callback)
        {
            int configFrameRate = frameRate;
            if (int.TryParse(Configurator.getNodeValue("globals", "PedigreeFrameRate"), out configFrameRate))
                frameRate = configFrameRate;

            animationThread.WorkerReportsProgress = true;
            animationThread.WorkerSupportsCancellation = true;
            animationThread.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e)
            {
                try
                {
                    while (animate && animationThread.CancellationPending==false)
                    {
                        //Thread.Sleep(100);
                        Thread.Sleep(frameRate);
                        animationThread.ReportProgress(0);
                    }
                }
                catch { }
            });
            animationThread.ProgressChanged += new ProgressChangedEventHandler(
                delegate(object sender, ProgressChangedEventArgs e) {
                    animate = callback();
                });
            animationThread.RunWorkerAsync();
        }
Esempio n. 2
0
        public void SpawnAnimationThread(PerFrameCallback callback)
        {
            int configFrameRate = frameRate;

            if (int.TryParse(Configurator.getNodeValue("globals", "PedigreeFrameRate"), out configFrameRate))
            {
                frameRate = configFrameRate;
            }

            animationThread.WorkerReportsProgress      = true;
            animationThread.WorkerSupportsCancellation = true;
            animationThread.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e)
            {
                try
                {
                    while (animate && animationThread.CancellationPending == false)
                    {
                        //Thread.Sleep(100);
                        Thread.Sleep(frameRate);
                        animationThread.ReportProgress(0);
                    }
                }
                catch { }
            });
            animationThread.ProgressChanged += new ProgressChangedEventHandler(
                delegate(object sender, ProgressChangedEventArgs e) {
                animate = callback();
            });
            animationThread.RunWorkerAsync();
        }