创建多个实例 [英] Creating multi instances

查看:91
本文介绍了创建多个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,
我正在使用Windows应用程序3.5.我在这里使用线程
我必须运行另一个Windows应用程序.它工作正常,但仍在继续创建新实例.那就是问题所在.请给我建议.
我的代码是:

Hi friends,
I am working on windows application 3.5. Here I am using thread in that
I have to run another wondows application. It working fine but it is keep on creating new instance. That is the problem. Pls give me sugg.
My code is:

public void runclient()
{
Client objclient = new Client();
objclient.CallerID = callerID;
objclient.Request = ivrsRequest;
Application.Run(objclient);
} 



在这里继续创建客户表单的实例.
感谢



Here keep on creating instance of Client Form.
Thanks

推荐答案

代码正在完全按照您的要求进行操作.如果您希望它做一些不同的事情,请不要在每次运行时都继续运行任何应用程序.如果Application.Run返回一个Handle,则可以检查该句柄是否仍处于打开状态,等等,并且仅在需要时才运行它.
The code is doing exactly what you ask it to. If you want it to do something different, don''t keep running any app every time it is run. If Application.Run returns a Handle, you could check if that handle is still open, etc, and run it only if you need to ?


是否必须同时使用2种形式时间?
这是您要找的东西吗?

Do you have to use 2 forms at the same time?
Is this what you are looking for?

public void runclient()
{
Client objclient = new Client();
objclient.CallerID = callerID;
objclient.Request = ivrsRequest;
objclient.ShowDialog();
objclient.Dispose();
}



或这样处理表单并将变量引用设置为null
在关机的某个地方?



Or perhaps this and dispose the form and set variable reference to null
somewhere on shutdown?

Client objclient;
public void runclient()
{
 if(objclient == null)
 {
 objclient = new Client();
 objclient.CallerID = callerID;
 objclient.Request = ivrsRequest;
 Application.Run(objclient);
 }
}


这篇关于创建多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆