G
Guest
I have the following invocation in my application:
private delegate void InitializeDataDelegate();
/// <summary>Loads information from the database.</summary>
public void InitializeData()
{
if(InvokeRequired)
{
Invoke(new InitializeDataDelegate(this.InitializeData));
}
else
{
blah...blah...blah
}
}
Sometimes, this asserts as so:
EventMananager Callback.
Message: Specified cast is not valid.
Stack Trace: at System.Windows.Forms.Control.MarshaledInvoke( Control
caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.Invoke(Delegate method)
at XXXX.XXX.XXX.MyBaseForm.InitializeData() in c:\myfile.cs, line xxx
....
at EventManager.EventHandlerThread() ...
I am not sure what cast is invalid as I have no parameters in my Invoke
call. Could it be the delegate method itself? The documentation says I
could call Invoke with the object args as null, but that seems to me to be
the same thing as not passing a second parameter at all. This happens very
infrequently so I have not been able to repeat the process and find out what
is happening.
Can anyone shed some light on this for me?
Thanks,
Ken
private delegate void InitializeDataDelegate();
/// <summary>Loads information from the database.</summary>
public void InitializeData()
{
if(InvokeRequired)
{
Invoke(new InitializeDataDelegate(this.InitializeData));
}
else
{
blah...blah...blah
}
}
Sometimes, this asserts as so:
EventMananager Callback.
Message: Specified cast is not valid.
Stack Trace: at System.Windows.Forms.Control.MarshaledInvoke( Control
caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.Invoke(Delegate method)
at XXXX.XXX.XXX.MyBaseForm.InitializeData() in c:\myfile.cs, line xxx
....
at EventManager.EventHandlerThread() ...
I am not sure what cast is invalid as I have no parameters in my Invoke
call. Could it be the delegate method itself? The documentation says I
could call Invoke with the object args as null, but that seems to me to be
the same thing as not passing a second parameter at all. This happens very
infrequently so I have not been able to repeat the process and find out what
is happening.
Can anyone shed some light on this for me?
Thanks,
Ken