How to call dynamically loaded Assemblies Method asynchronously,...?

K

Kerem Gümrükcü

Hi,

i have a (simple) dynamic plugin architecture and i want
to call a member function from the dynamically loaded
assembly and its instanciated class. The Code looks like
this:

foreach (KeyValuePair<string, Assembly> PlugInAssembly in
dictAvailablePlugins)
{
try
{
Object oRestartsPluginEntryClass =
PlugInAssembly.Value.CreateInstance(PlugInAssembly.Value.GetName().Name +
".RestartsPluginEntryClass", true);
if (oRestartsPluginEntryClass != null)
{
MethodInfo miRestartsServiceError =
oRestartsPluginEntryClass.GetType().GetMethod("RestartsServiceError");
if (miRestartsServiceError != null)
{
miRestartsServiceError.Invoke(oRestartsPluginEntryClass, new object[] {
SourceProcess, SourceService, e });
}
}

But i want the "Invoke" asynchronously made, something like
"BeginInvoke".How can this be done?


Regards

Kerem


--
 
J

Jeroen Mostert

Kerem said:
Hi,

i have a (simple) dynamic plugin architecture and i want
to call a member function from the dynamically loaded
assembly and its instanciated class. The Code looks like
this:

foreach (KeyValuePair<string, Assembly> PlugInAssembly in
dictAvailablePlugins)
{
try
{
Object oRestartsPluginEntryClass =
PlugInAssembly.Value.CreateInstance(PlugInAssembly.Value.GetName().Name +
".RestartsPluginEntryClass", true);
if (oRestartsPluginEntryClass != null)
{
MethodInfo miRestartsServiceError =
oRestartsPluginEntryClass.GetType().GetMethod("RestartsServiceError");
if (miRestartsServiceError != null)
{
miRestartsServiceError.Invoke(oRestartsPluginEntryClass, new object[] {
SourceProcess, SourceService, e });
}
}

But i want the "Invoke" asynchronously made, something like
"BeginInvoke".How can this be done?
Delegate.CreateDelegate().
 
K

Kerem Gümrükcü

Hi Jeroen,

thanks for the Response. Nice Solution, but i wrote a delegate for
each call, like this:

private delegate void NotifyPluginsServiceStartedDelegate(Process
SourceProcess, ServiceController SourceService);
....
notifyPlgServiceStarted = new
NotifyPluginsServiceStartedDelegate(NotifyPluginsServiceStarted);
....
notifyPlgServiceStarted.BeginInvoke(Process.GetCurrentProcess(), sc, null,
null);


But your solution is a good option for the future,...

Thanks!

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Jeroen Mostert said:
Kerem said:
Hi,

i have a (simple) dynamic plugin architecture and i want
to call a member function from the dynamically loaded
assembly and its instanciated class. The Code looks like
this:

foreach (KeyValuePair<string, Assembly> PlugInAssembly in
dictAvailablePlugins)
{
try
{
Object oRestartsPluginEntryClass =
PlugInAssembly.Value.CreateInstance(PlugInAssembly.Value.GetName().Name +
".RestartsPluginEntryClass", true);
if (oRestartsPluginEntryClass != null)
{
MethodInfo miRestartsServiceError =
oRestartsPluginEntryClass.GetType().GetMethod("RestartsServiceError");
if (miRestartsServiceError != null)
{
miRestartsServiceError.Invoke(oRestartsPluginEntryClass, new object[] {
SourceProcess, SourceService, e });
}
}

But i want the "Invoke" asynchronously made, something like
"BeginInvoke".How can this be done?
Delegate.CreateDelegate().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top