不同进程之间的对象的单个实例? [英] Single instance of an object between different processes?

查看:83
本文介绍了不同进程之间的对象的单个实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个由几个可执行文件组成的应用程序。我需要所有

这些可执行文件才能使用相同的对象实例。


最好,最有效的方法是什么?


非常感谢!

Hi,

I have an application that is made up of several executables. I need all
these executables to use the same instance of an object.

What is the best, most efficient way to approach this?

Thanks a lot!

推荐答案

阅读Mutex'或查看CodeProject上的这篇文章

解释了如何做到这一点:

http://www.codeproject.com/csharp/singleinstance.asp

希望这会有所帮助。


-

Brian Delahunty

爱尔兰

http://briandela.com/blog

INDA SouthEast - http://southeast.developers.ie/ - .NET用户组I

始于爱尔兰东南部。

Elad写道:
Read up on Mutex''s or check out this article on the CodeProject which
explains how to do it:

http://www.codeproject.com/csharp/singleinstance.asp

Hope this helps.

--
Brian Delahunty
Ireland

http://briandela.com/blog

INDA SouthEast - http://southeast.developers.ie/ - The .NET usergroup I
started in the southeast of Ireland.
"Elad" wrote:


我有一个由几个可执行文件组成的应用程序。我需要所有
这些可执行文件来使用相同的对象实例。

最好,最有效的方法是什么?

非常感谢!
Hi,

I have an application that is made up of several executables. I need all
these executables to use the same instance of an object.

What is the best, most efficient way to approach this?

Thanks a lot!






您可以创建一个(静态)类并将对象公开为一个静态成员

这个类:


公共静态类Globals //''static''这里只在C#2.0中有效

{

//全球实例

private static TheClass theObject;

//公开实例的公共属性

public static TheClass TheObject {get {return theObject; } $

//类构造函数 - 在加载类时执行

Globals()

{

//创建并初始化全局实例

theObject = new TheClass();

//等等

}

}


应用程序可以通过Globals引用此对象。对象。


问候 - Octavio


" Elad" <埃尔********* @ hotZZZmail.com> escribióenel mensaje

news:Ob **************** @ tk2msftngp13.phx.gbl ...
Hi,

You can create a (static) class and expose the object as a static member of
this class:

public static class Globals // ''static'' here only valid in C# 2.0
{
// the "global" instance
private static TheClass theObject;
// a public property that exposes the instance
public static TheClass TheObject { get { return theObject; } }
// class constructor - executed when class is loaded
Globals()
{
// create and initialize "global" instance
theObject = new TheClass();
// etc.
}
}

Applications can reference this object by Globals.TheObject.

Regards - Octavio

"Elad" <El*********@hotZZZmail.com> escribió en el mensaje
news:Ob****************@tk2msftngp13.phx.gbl...


我有一个由几个可执行文件组成的应用程序。我需要所有
这些可执行文件来使用相同的对象实例。

最好,最有效的方法是什么?

非常感谢!
Hi,

I have an application that is made up of several executables. I need all
these executables to use the same instance of an object.

What is the best, most efficient way to approach this?

Thanks a lot!



你也可以在这里使用远程处理,并使用单例中的对象

实例化模式

-

Vadym Stetsyak又名Vadmyst


" Brian Delahunty" <峰; br ************ @ discussions.microsoft.com>写在

消息新闻:6F ********************************** @ microsof t.com ...
You can also use remoting here, and use the object in the singletone
instantiation pattern

--
Vadym Stetsyak aka Vadmyst

"Brian Delahunty" <Br************@discussions.microsoft.com> wrote in
message news:6F**********************************@microsof t.com...
阅读Mutex'或查看CodeProject上的这篇文章,它解释了如何做到这一点:

http://www.codeproject.com/csharp/singleinstance.asp

希望这会有所帮助。

-
Brian Delahunty
爱尔兰

http://briandela.com/blog

INDA SouthEast - http://southeast.developers.ie/ - .NET用户组I
始于爱尔兰东南部。 />
" Elad"写道:
Read up on Mutex''s or check out this article on the CodeProject which
explains how to do it:

http://www.codeproject.com/csharp/singleinstance.asp

Hope this helps.

--
Brian Delahunty
Ireland

http://briandela.com/blog

INDA SouthEast - http://southeast.developers.ie/ - The .NET usergroup I
started in the southeast of Ireland.
"Elad" wrote:


我有一个由几个可执行文件组成的应用程序。我需要
所有这些可执行文件才能使用相同的对象实例。

最好,最有效的方法是什么?

非常感谢!
Hi,

I have an application that is made up of several executables. I need all these executables to use the same instance of an object.

What is the best, most efficient way to approach this?

Thanks a lot!



这篇关于不同进程之间的对象的单个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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