Animatroller.Simulator.SimulatorForm.SimulatorForm C# (CSharp) Method

SimulatorForm() public method

public SimulatorForm ( ) : System
return System
        public SimulatorForm()
        {
            InitializeComponent();

            this.SetStyle(
              ControlStyles.AllPaintingInWmPaint |
              ControlStyles.UserPaint |
              ControlStyles.DoubleBuffer, true);

            this.updateActions = new List<Action>();
            this.cancelSource = new System.Threading.CancellationTokenSource();
            this.senderTask = new Task(x =>
            {
                while (!this.cancelSource.IsCancellationRequested)
                {
                    lock (this.updateActions)
                    {
                        foreach (var action in this.updateActions)
                            action();
                    }

                    System.Threading.Thread.Sleep(100);
                }
            }, this.cancelSource.Token, TaskCreationOptions.LongRunning);

            this.senderTask.Start();
        }