PowerArgs.Cli.LifetimeManager.Manage C# (CSharp) Method

Manage() public method

public Manage ( IDisposable item ) : void
item IDisposable
return void
        public void Manage(IDisposable item)
        {
            _managedItems.Add(item);
        }

Usage Example

Example #1
0
        private void Added()
        {
            LifetimeManager.Manage(Application.SetInterval(() =>
            {
                var fore  = r.NextDouble() < .4;
                var pixel = Add(new PixelControl()
                {
                    CanFocus = false,
                    Value    = new ConsoleCharacter((char)r.Next((int)'a', (int)'z'),
                                                    foregroundColor: fore ? ConsoleColor.Green : ConsoleColor.Black,
                                                    backgroundColor: fore ? ConsoleColor.Black : (r.NextDouble() < .5 ? ConsoleColor.Green : ConsoleColor.DarkGreen)),
                    X = r.Next(0, Width)
                });

                LifetimeManager.Manage(Application.SetInterval(() =>
                {
                    if (pixel.Y < Height)
                    {
                        pixel.Y++;
                    }
                    else
                    {
                        this.Controls.Remove(pixel);
                    }
                }, TimeSpan.FromMilliseconds(r.Next(20, 100))));
            }, TimeSpan.FromMilliseconds(r.Next(10, 15))));
        }
All Usage Examples Of PowerArgs.Cli.LifetimeManager::Manage