Compartiendo para dos mundos

Hablando de programación paralela.
Tutoriales en: https://www.youtube.com/user/jambrizgdl
Twitter: @dogoteacher

Buscar este blog

viernes, 19 de marzo de 2010

Example of threads and Application.Run with two forms

In this code, Main method generate two applications in differents threads


using System;
using System.Windows.Forms;
using System.Threading;

/*
@descrip Execute two forms with "application.run" method.
@autor José Jesús Ambriz Meza
@fecha 19/03/2010
@version 1
*/
namespace variasVentanas
{
public class ventana: Form
{
public ventana(string t)
{
this.Text= t;
}

//start method for threading
public void inicio()
{
Application.Run( this ); //start this application
}

public static void Main()
{
//new ventana object ( form object )
ventana obj1= new ventana("uno");
//new ventana object ( form object )
ventana obj2= new ventana("dos");
//new thread with obj1
Thread t1= new Thread( obj1.inicio );
//new thread with obj2
Thread t2= new Thread( obj2.inicio );
//execute Application.Run with obj1
t1.Start();
//execute Application.Run with obj2
t2.Start();
}
}
}

No hay comentarios:

Publicar un comentario

Are you ready?