A
Alexander
Me again... 
I am running a small borderless dialog in a seperate thread, that
shows a small animation and I want to signal it to close itself. But I
am running in a System.ArgumentException which I do not understand
because I do not have any arguments.
Here is what I am doing:
-----------------------------------------------------
namespace MyNamespace
{
// delegate declaration
public delegate void CloseDialogDelegate();
// the dialog showing a animation
public class MyDialog : System.Windows.Forms.Form
{
public CloseDialogDelegate m_CloseDialog;
public WorkingDialog()
{
this.m_CloseDialog = new CloseDialogDelegate(CloseDialog);
...
}
...
public void CloseDialog()
{
this.Close();
}
}
///////////////////////////////////////////////////////////
// the big main program
public class MyMainForm : System.Windows.Forms.Form
{
private MyDialog m_MyDialog;
private Thread m_MyDialogThread;
...
private void MyDialogThreadFunc()
{
Application.Run(this.m_MyDialog = new MyDialog());
}
private ShowMyDialog()
{
this.m_MyDialogThread = new Thread(new
ThreadStart(MyDialogThreadFunc));
this.m_MyDialogThread.Start();
}
private CloseMyDialog()
{
// System.ArgumentException
this.m_MyDialog.Invoke(this.m_MyDialog.m_CloseDialog);
}
private DoSomeWork()
{
this.ShowDialog();
...
// Do some excessive Work, including
// preparing some UI stuff of this form.
...
this.CloseDialog();
}
...
}
}
-----------------------------------------------------
The exception is a System.ArgumentException with additional
information ArgumentException. Strange is especially that the compact
..NET framework does not support any Invoke function which passes
arguments....
I am confused...
Alexander

I am running a small borderless dialog in a seperate thread, that
shows a small animation and I want to signal it to close itself. But I
am running in a System.ArgumentException which I do not understand
because I do not have any arguments.
Here is what I am doing:
-----------------------------------------------------
namespace MyNamespace
{
// delegate declaration
public delegate void CloseDialogDelegate();
// the dialog showing a animation
public class MyDialog : System.Windows.Forms.Form
{
public CloseDialogDelegate m_CloseDialog;
public WorkingDialog()
{
this.m_CloseDialog = new CloseDialogDelegate(CloseDialog);
...
}
...
public void CloseDialog()
{
this.Close();
}
}
///////////////////////////////////////////////////////////
// the big main program
public class MyMainForm : System.Windows.Forms.Form
{
private MyDialog m_MyDialog;
private Thread m_MyDialogThread;
...
private void MyDialogThreadFunc()
{
Application.Run(this.m_MyDialog = new MyDialog());
}
private ShowMyDialog()
{
this.m_MyDialogThread = new Thread(new
ThreadStart(MyDialogThreadFunc));
this.m_MyDialogThread.Start();
}
private CloseMyDialog()
{
// System.ArgumentException
this.m_MyDialog.Invoke(this.m_MyDialog.m_CloseDialog);
}
private DoSomeWork()
{
this.ShowDialog();
...
// Do some excessive Work, including
// preparing some UI stuff of this form.
...
this.CloseDialog();
}
...
}
}
-----------------------------------------------------
The exception is a System.ArgumentException with additional
information ArgumentException. Strange is especially that the compact
..NET framework does not support any Invoke function which passes
arguments....
I am confused...
Alexander