Thanks, for repsonding;
I now know the cause of the problem but not the solution. I am using
Process in System.Diagnostics to launch an application. On it's exit I
launch the Window form and then display it, it is displayed and then
freezes. Code follows;
The class library that launches the form...
using System;
using System.Threading;
using System.Diagnostics;
namespace LaunchWindowFromDllMain
{
public class Class1
{
static Form1 _form1;
private Process _process=null;
public Class1()
{
}
public void TestActivateWindow(){
_process = new Process();
_process.StartInfo.FileName = "notepad.exe";
_process.StartInfo.Arguments= "";
_process.StartInfo.WorkingDirectory="";
_process.Disposed += new EventHandler(DisposedHandler);
_process.Exited += new EventHandler(ExitHandler);
_process.EnableRaisingEvents = true;
_process.Start();
}
private void DisposedHandler(object sender, EventArgs e) {
Console.WriteLine("Disposed...");
}
private void ExitHandler(object sender, EventArgs e) {
_process.Dispose();
_process=null;
Console.WriteLine("Exited...");
_form1=new Form1();
_form1.Show(); <--after form is displayed it is frozen------------
}
}
}
---the form that is launched in class library dll----
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace LaunchWindowFromDllMain
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private bool _toggle=false;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
#endregion
private void button1_Click(object sender, System.EventArgs e) {
if(_toggle==true)
this.textBox1.BackColor=System.Drawing.Color.LightBlue;
else
this.textBox1.BackColor=System.Drawing.Color.Red;
_toggle=!_toggle;
}
}
}
----The main aapplication that launches the classLibrary dll------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace LaunchWindowFromDllMain
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
private Class1 _Class1=null;
public Form1()
{
InitializeComponent();
_Class1=new Class1();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e) {
_Class1.TestActivateWindow();
}
}
}
do
form