Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/09/2005, 12:56
Avatar de xknown
xknown
 
Fecha de Ingreso: diciembre-2004
Ubicación: Cusco - Perú
Mensajes: 2.248
Antigüedad: 19 años, 4 meses
Puntos: 7
No es necesario, aquí tienes otra alternativa para tener formularios únicos:
Código:
public static SortedList formInstances = new SortedList(); // Para guardar las referencias de las instancias de los formularios
public static Form AbrirVentana(Type type)
{
	return AbrirVentana(type, false);
}
public static Form AbrirVentana(Type type, bool dialog)
{
	Form formulario;
	if ( (formulario = (Form) formInstances[type.ToString()]) == null || formulario.IsDisposed) 
	{
		formulario = ( Form ) Activator.CreateInstance( type );
		formInstances[type.ToString()] = formulario;
	}
	
	formulario.Activate();
	formulario.WindowState = FormWindowState.Normal;
	if (dialog) 		
		formulario.ShowDialog();
	else
		formulario.Show();

	return formulario;
}
Lo usas de la siguiente manera:

Form1 un_formulario = (Form1)AbrirVentana(typeof(Form1));

Saludos
PS. Personalmente no utilizaría el patrón Singleton para estos casos.
__________________
Alex Concha
Buayacorp - Programación y Diseño