Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/04/2012, 22:29
Avatar de ramirezmario7
ramirezmario7
 
Fecha de Ingreso: febrero-2008
Ubicación: Medellín
Mensajes: 336
Antigüedad: 17 años, 2 meses
Puntos: 56
Respuesta: un timer en una dll

Hola.
Estuve probando y de pronto te sirve este código.
Pruébalo y comenta como te fue.

La DLL
Código:
using System;
using System.Windows.Forms;


namespace Contador
{
    public class contador
    {
        private Timer objtimer = new Timer();
        private TextBox txt;

        public contador(TextBox textBox)
        {
            Segundos = 0;
            objtimer.Start();
            objtimer.Tick += new EventHandler(objtimer_Tick);
            objtimer.Interval = 100;
            txt = textBox;
            
        }

        void objtimer_Tick(object sender, EventArgs e)
        {
            Segundos++;
            txt.Text = Segundos.ToString();
        }

        private int Segundos { get; set; }
    }
}
codigo en el formulario que usa la dll
Código:
using System;
using System.Windows.Forms;
using Contador;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }        

        private void Form2_Load(object sender, EventArgs e)
        {
            contador obj = new contador(this.textBox1);
        }
    }
}
__________________
Mario Ramírez
Desarrollador .NET MCTS
https://www.mcpvirtualbusinesscard.c...nteractivecard