473,698 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invoking methods in assembly in dl causes main thread to wait?

Hi,

I am working on an application that can use functionlity in some sort of
plugins. I have implemented this by using Assembly.LoadFr om and
MethodInfo.GetM ethods.

The calling of the plugins is handled in threads.

All works fine, but when I call a method that processes for some time, the
mainthread (my form) becomes unresponsive.

I do not understand why and do not know how else to implement this. Does
anyone have suggestions?

Cheers,
Michel Schilthuizen

Code:

int ret;
Object medium;
MethodInfo mConfig;

----Initialisation of medium and mconfig was taken out, too much
code!! -----
ret = (int) mConfig.Invoke( medium, null);
Nov 15 '05 #1
2 3220
Hi Michel,

Provided that your plug-ins do not interact with the main program UI in an
unpredicted manner, you should use BeginInvoke and EndInvoke to call
plug-ins' methods asynchronously.

There has been a serie of articles published on MSDN called "Safe, Simple
Multi-threading in Windows Forms" where different ways of running
time-consuming tasks in the backgroud were given.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Unit Testing and Integration Environment
http://x-unity.miik.com.ua
Deliver reliable .NET software

"Michel Schilthuizen" <bu**@deputy.ho meip.net> wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I am working on an application that can use functionlity in some sort of
plugins. I have implemented this by using Assembly.LoadFr om and
MethodInfo.GetM ethods.

The calling of the plugins is handled in threads.

All works fine, but when I call a method that processes for some time, the
mainthread (my form) becomes unresponsive.

I do not understand why and do not know how else to implement this. Does
anyone have suggestions?

Cheers,
Michel Schilthuizen

Code:

int ret;
Object medium;
MethodInfo mConfig;

----Initialisation of medium and mconfig was taken out, too much
code!! -----
ret = (int) mConfig.Invoke( medium, null);


Nov 15 '05 #2
Michel,

If you launch your plug-ins on another threads, you just don't need
BeginInvoke and EndInvoke as they simply run the passed delegate on a
separate thread taken from a dedicated thread pool. To be honest, I am out
of ideas what could lock up the GUI thread then.

I would suggest throughly checking the communication pattern between the GUI
thread and the other threads - for example, that no continuous polling exist
from the GUI thread.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Unit Testing and Integration Environment
http://x-unity.miik.com.ua
Deliver reliable .NET software

"Michel Schilthuizen" <bu**@deputy.ho meip.net> wrote in message
news:eV******** ******@TK2MSFTN GP09.phx.gbl...
Hi Dmitriy,

Thanks for your response. I understand the invoke functionality a lot better now. However, BeginInvoke does not seem to be a member of the MethodInfo
object.

I don't think I properly explained what I am trying to do, so I'll quickly
try again and would appreciate it if you could let me know how (and if) your solution could fit.

I have my main thread, which starts a 'core' thread. This 'core' completely runs on its own, but will log to the main window in the future.

The 'core' thread reads plugin information from an ini file and starts
threads accordingly. These threads will use GetMethod and invoke, to call
methods in an assembly in a dll. The core will poll all plugin threads for
available information that needs to go to the other plugins. (Using a shared object, with monitor to synch)

The plugin threads are used to poll the 'dll's' for information. These calls may take a long time (web service calls, or a sleep in my test as I was
suspecting the web calls to be the cause). (In my test I only have one
plugin looking for information)

The mainthread is not doing anything at this time. When I want to select a
menu item, while one of the threads is making a call (using
MethodInfo.Invo ke), the form just does not respond.

I will use your Begin and EndInvoke for the logging to the user interface,
but before I do that, I would like to solve this issue, because as far as I am aware the action in the thread should not at all influence the
performance of the mainthread. (unless it is using a lot of CPU offcourse!)
I hope you can help me out again,
Michel

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:#4******** *****@tk2msftng p13.phx.gbl...
Hi Michel,

Provided that your plug-ins do not interact with the main program UI in an
unpredicted manner, you should use BeginInvoke and EndInvoke to call
plug-ins' methods asynchronously.

There has been a serie of articles published on MSDN called "Safe, Simple Multi-threading in Windows Forms" where different ways of running
time-consuming tasks in the backgroud were given.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Unit Testing and Integration Environment
http://x-unity.miik.com.ua
Deliver reliable .NET software

"Michel Schilthuizen" <bu**@deputy.ho meip.net> wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I am working on an application that can use functionlity in some sort of plugins. I have implemented this by using Assembly.LoadFr om and
MethodInfo.GetM ethods.

The calling of the plugins is handled in threads.

All works fine, but when I call a method that processes for some time,

the mainthread (my form) becomes unresponsive.

I do not understand why and do not know how else to implement this. Does anyone have suggestions?

Cheers,
Michel Schilthuizen

Code:

int ret;
Object medium;
MethodInfo mConfig;

----Initialisation of medium and mconfig was taken out, too much
code!! -----
ret = (int) mConfig.Invoke( medium, null);



Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6523
by: Hamed Seifoddini | last post by:
Hi. This might be answered before, but I couldn't find it. How can you make the main thread to wait() This does NOT work : Thread.currentThread().wait(); Regards,
99
5892
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
3
1469
by: Nick | last post by:
My client uses a SQL Database to store their usernames and passwords, and I do not believe they have AD...no big deal... I wrote a class to create a generic identity and generic principal so that I can use the .IsInRole function for some added security. I would like to do the same by applying an attribute to a method or class. The code I am including works from what I can see, but I am experiencing the following... 1) I cannot add the...
3
1532
by: Daniel | last post by:
how do i access methods when the .net assembly was loaded with late biding? class Class1 { public static void Main() { System.Reflection.Assembly SampleAssembly; SampleAssembly = System.Reflection.Assembly.LoadFrom("C:\\SimpleSolutions\\asmload\\asmtoload \\bin\\Debug\\asmtoload.dll");
2
7766
by: Jeff | last post by:
I am trying to dynamically load an assembly via reflection and then invoke a method of that assembly that will populate a custom type collection passed into the method byref. I am able to dynamically load both the DALC component (for the method call) and the Entity component (for the custom type collection to pass in), but I keep getting an error ( Message "Object type cannot be converted to target type.") when invoking the method. If I...
25
2504
by: MuZZy | last post by:
Hi, I'm currently rewriting some functionality which was using multithredaing for retrieving datasets from database and updating a grid control. I found that the grids (Infragistics UltraGrid, though it doesn't matter) were updated (i.e. grid.DataSource = dsDataSet;) and used for different purposes in the worker thread, so now i'm wrapping all those calls to grid's methods thru invoking which is a pain in the a$$ considering number of...
6
1417
by: Diego F. | last post by:
Hello. I'm using the socket class in an application and I use socket.receive to wait for data. The problem is that the interface gets locked while the receive method is executing. I want to see the interface so the user knows what's happening at any time. Is that possible? --
6
2738
by: DaTurk | last post by:
I know in a WinForm you can check if an Invoke is inquired and invoke a method on the main thread. But can you do this in a class? Can I call Invoke(someMethod) in my asynch event handler? And if I can't do it this way, is there a way I can do it? Thanks.
2
5565
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the serialization settings for the build handled the initial slows we encountered when invoking the web service. Since that time, we ported the original VB.net code over to C# - this was done to make it cleaner easier to include the project in the rest of...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.