A
Alexander
Me again.... second time I type this - the post did not work the first
time...
Similar question as last time, but another problem:
I am running a CE.Net Application and I want to show a small
borderless dialog which shows an animation, that shows, that the
application is still doing something. So far it works until I want to
close the dialog. The dialog has a delegate that I want to invoke,
which will close it. But I run into a System.ArgumentException with
additional Information 'ArgumentException' if I want to invoke the
delegate.
Here is what I am trying to do:
--------------------------------------------------
namespace MyNamespace
{
public delegate void CloseDialogDelegate();
public class MyDialog : System.Windows.Forms.Form
{
public CloseDialogDelegate m_CloseDialog;
public MyDialog()
{
this.m_CloseDialog = new CloseDialogDelegate(CloseDialog);
...
}
...
private void CloseDialog()
{
this.Close();
}
}
public class MainForm : System.Windows.Forms.Form
{
private MyDialog m_MyDialog;
private Thread m_MyDialogThread;
...
private void MyDialogThreadFunc()
{
Application.Run(this.m_MyDialog = new MyDialog());
}
private void OpenMyDialog()
{
this.m_MyDialogThread = new Thread(new
ThreadStart(MyDialogThreadFunc));
this.m_MyDialogThread.Start();
}
private void CloseMyDialog()
{
// here happens the System.ArgumentException
this.m_MyDialog.Invoke(this.m_MyDialog.m_CloseDialog);
}
...
private void DoSomeWork()
{
this.OpenMyDialog();
// Do some work, including excessive
// UI stuff for this form
...
this.CloseMyDialog();
}
}
}
-----------------------------------------------------------
I am confused... I do not even pass arguments to the other thread, the
delegate has no arguments and CF.Net does not support an Invoke with
arguments...
What happens here?
Alexander
time...
Similar question as last time, but another problem:
I am running a CE.Net Application and I want to show a small
borderless dialog which shows an animation, that shows, that the
application is still doing something. So far it works until I want to
close the dialog. The dialog has a delegate that I want to invoke,
which will close it. But I run into a System.ArgumentException with
additional Information 'ArgumentException' if I want to invoke the
delegate.
Here is what I am trying to do:
--------------------------------------------------
namespace MyNamespace
{
public delegate void CloseDialogDelegate();
public class MyDialog : System.Windows.Forms.Form
{
public CloseDialogDelegate m_CloseDialog;
public MyDialog()
{
this.m_CloseDialog = new CloseDialogDelegate(CloseDialog);
...
}
...
private void CloseDialog()
{
this.Close();
}
}
public class MainForm : System.Windows.Forms.Form
{
private MyDialog m_MyDialog;
private Thread m_MyDialogThread;
...
private void MyDialogThreadFunc()
{
Application.Run(this.m_MyDialog = new MyDialog());
}
private void OpenMyDialog()
{
this.m_MyDialogThread = new Thread(new
ThreadStart(MyDialogThreadFunc));
this.m_MyDialogThread.Start();
}
private void CloseMyDialog()
{
// here happens the System.ArgumentException
this.m_MyDialog.Invoke(this.m_MyDialog.m_CloseDialog);
}
...
private void DoSomeWork()
{
this.OpenMyDialog();
// Do some work, including excessive
// UI stuff for this form
...
this.CloseMyDialog();
}
}
}
-----------------------------------------------------------
I am confused... I do not even pass arguments to the other thread, the
delegate has no arguments and CF.Net does not support an Invoke with
arguments...
What happens here?
Alexander