Two Widows Applications problem:

L

LearnMore.John

I have two Windows Desktop applications App1 and App2.
App1 is invoking Appp2 using Reflection.
When App2 application opens a Modal window, App1 Application also
freezes
I dont want to happen this, how can i avoid this.

Sample code how i am invoking App2 from App1

Assembly a;
a = Assembly.LoadFrom(installDir + @"\App2 .exe");
object[] args = new object[3];
args[0] = ideWSPath
args[1] = this.Size;
args[2] = this.Location;
Instance = a.CreateInstance("App2.frmMain", false,
BindingFlags.CreateInstance, null, args, null, null);
((System.Windows.Forms.Form)nstance).Show();

thanks in advance
 
J

Justin

The generic answer would be that anytime you're having problems with a
GUI's response time, consider using Threads. This way when a thread is
blocking your GUI keeps going. I'm not sure how thread safe Reflection
is, so that may be an issue, but I'm sure there's a way around it.
Depending on how much time App2 causes the thread on App1 to block you
either want to use the System.Threading Thread class or the ThreadPool
class. If you need more information then this just post a reply.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Is the second app a windows app or a dll?

It should be a dll, or in other words it should not contain a message pump,
otherwise you will get in trouble with the previous one.

why are you doing this? what are you tring to do?

cheers,
 
S

Simon Watson

It looks to me like App2.frmMain is being run from inside the same process
as App1, in which case, I don't think there's anything you can do. Modal
forms freeze all other windows in a process. I suspect the cure would be to
create a second process to run App2 in.
 
W

Willy Denoyette [MVP]

You don't have two applications, you load the app2.exe assembly in the
current application App1 and you Load/show a form from that assembly, that
means you have one single application (single Application Domain) and one
single thread that runs the (Modal) form, that means no other threads can
run as long as the Form is shown.
Willy.
 
R

ramonc99

if you designate app1 as the mdi parent and embed the main form into
app1, you can bypass the issues you are running into. If you have to
have app2 run as a window, make the necessary modifications to app2 to
open as a modal dialog on instantiation.

rc
 
L

LearnMore.John

Thank u all for ur responses

i am using reflection to have complete control over
application (i am closing and opening the applcation in some conditions
and just in case if i have to call some of the methods of App2 in the
future),
Using Process object will create more problems for me

i guesss there is no soln as indicated by simon and willy.

Is there any way to achieve the effect of Modal window without
using ShowDialog function?

thanks
regards
 

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

Top