运行程序的多个实例 [英] Running multiple instances of a program

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

问题描述

我刚刚在VB.NET中完成了一个WinForms应用程序。我想让用户能够像记事本和

Wordpad那样运行多个程序实例。现在的样子,一旦我运行可执行文件,只要第一个实例运行,我就无法运行另一个

实例。我怎样才能改变这个

的行为?谢谢。

I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and
Wordpad. The way it is now, once I run the executable I can not run another
instance as long as the first instance is running. How can I change this
behavior? Thanks.

推荐答案

*" Clark Stevens" < CY ********* @ hotmail.com> scripsit:
* "Clark Stevens" <cy*********@hotmail.com> scripsit:
我刚刚在VB.NET中完成了一个WinForms应用程序。我希望允许用户能够像记事本和
写字板一样运行程序的多个实例。现在的方式,一旦我运行可执行文件,只要第一个实例正在运行,我就无法运行另一个实例。如何更改此行为?
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and
Wordpad. The way it is now, once I run the executable I can not run another
instance as long as the first instance is running. How can I change this
behavior?




您要做的是默认行为。防止应用程序

多次运行需要额外的代码。


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>

< URL:http://dotnet.mvps.org/dotnet/faqs/ >



What you want to do is the default behavior. Preventing the application
from running more than once would require additional code.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>


Clark,


默认设置是允许您根据需要运行任意数量的实例。


使用1表单创建一个小型测试项目。在Visual Studio中运行项目

,以便创建bin目录并构建.exe。

退出Visual Studio并导航到项目bin目录。


双击.exe并观察表单显示。


再次双击.exe并观察第二个表单显示。


....


-Sam Matzen

" Clark Stevens" < CY ********* @ hotmail.com>在消息中写道

新闻:yE ******************* @ twister.nyroc.rr.com ...
Clark,

The default is to allow you to run as many instances as you want.

Create a small test project with 1 form. Run the project in Visual Studio
so the bin directory is created and the .exe is built.

Exit Visual Studio and navigate to the projects bin directory.

Double-Click the .exe and observe the form displays.

Double-Click the .exe again and observe a second form displays.

....

-Sam Matzen
"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:yE*******************@twister.nyroc.rr.com...
我刚刚在VB.NET中完成了一个WinForms应用程序。我希望允许用户能够像记事本
和Wordpad一样运行程序的多个实例。现在的方式,一旦我运行可执行文件,只要第一个实例正在运行,我就无法运行
另一个实例。我该如何改变这种行为?谢谢。
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and Wordpad. The way it is now, once I run the executable I can not run another instance as long as the first instance is running. How can I change this
behavior? Thanks.



" Samuel L Matzen" < SM ***** @ slm.com>在消息中写道

news:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Clark,

默认情况下,允许您根据需要运行任意数量的实例。

使用1个表单创建一个小型测试项目。在Visual Studio中运行项目
以便创建bin目录并构建.exe。

退出Visual Studio并导航到项目bin目录。

双击.exe并观察表单显示。

再次双击.exe并观察第二个表单显示。
Clark,

The default is to allow you to run as many instances as you want.

Create a small test project with 1 form. Run the project in Visual Studio
so the bin directory is created and the .exe is built.

Exit Visual Studio and navigate to the projects bin directory.

Double-Click the .exe and observe the form displays.

Double-Click the .exe again and observe a second form displays.




好的,我做了这个,它确实运行了多个实例。但是,我已经在桌面上设置了一个快捷方式,它在程序的Bin

目录中启动了可执行文件。它似乎是允许多个

实例的快捷方式。每次我启动快捷方式时,它都不会运行另一个实例

的可执行文件。快捷方式是否有一些设置我需要改变什么?



Okay, I did this and it does run multiple instances. However, I have setup
a shortcut on the desktop which launches the executable in the program''s Bin
directory. It is the shortcut that doesn''t seem to allow the multiple
instances. Every time I launch the shortcut it doesn''t run another instance
of the executable. Is there some settings on the shortcut that I need to
change or something?


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

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