Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: blue5teel on January 21, 2009, 07:32:27 pm
-
Hello there,
some time ago i posted about a "server is busy"-dialog when i used ms word in my C#-addin (reporting-addin) for EA. I didnt find a solution for it.
Now i have a simliar problem with EA itself.
My addin exports the currently opened project, starts a second instance of EA and imports the lately exported project into it.
Then i apply the RTF-Documentation of EA to several packages in the second instance of EA. If the computation takes to much time a dialog appears with the message "server is busy" and the execution stops until i press "retry" on the dialog. How can i prevent this Dialog from popping up.
Why do i use a second instance of EA and not the original one:
I move elements and diagrams between packages. I had some problems after restoring the original locations of the elements: i didnt get the original structure back, but a persistent projectstructure is critical.
thank you in advance.
-
You could try to start a second thread in C# and there open the second EA instance, import stuff into it, run reports and so on. This should rid you of the dialog for good.
Could mean some work though. You'd have to test what happens when you close the first EA instance while the second thread is still running, and if your AddIn needs to know when the second thread has finished, you'll have to work with events. Some experience with threading, COM interop and asynchronous programming would be required, but I know of no other way to get rid of the "server busy" dialog.
-
Found a Solution here:
http://www.summsoft.com/blogs/melodys_vsta_blog/archive/2007/08/07/using-a-messagefilter-to-avoid-ide-threading-and-timing-issues.aspx
-
And does it work? The way I understand it, the link shows how to set a message filter for a .Net form, but how do you set it for EA's main window?
-
Yes it seems to work.. I didnt get any "server is busy"-dialogs since i integrated the IMessageFilter-Interface.
You seem to speak german:
I wrote some details in this forum:
http://www.c-plusplus.de/forum/viewtopic-var-t-is-232291.html
But i actually did copy and paste from the page i mentioned in my post above.
-
Does that mean your C# class (the public one which EA creates as COM object) implements IMessageFilter?
-
Does that mean your C# class (the public one which EA creates as COM object) implements IMessageFilter?
No, i created a class MessageFilter which implements IMessageFilter.
Then i integrated it in the EA_MenuClick-function in the main class (the one you are speaking of) like this:
public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName)
{
switch (ItemName)
{
case "&Dokument erstellen":
using (MessageFilter messageFilter = new MessageFilter())
{
// original contents are unchanged
ReportForm rf = new ReportForm();
rf.Show();
}
break;
}
}
Greetings
-
Thank you. That's an interesting piece of code.