DLL的唯一副本 [英] Unique copy of DLL

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

问题描述




我在VB.net编写了一个类库,它为一个

调用者提供了Props / Meths来隐藏TCP的uglinesses客户之间的消息协议

和服务器。


所有这一切都很好。


现在我是试图开发一个LOAD TESTER应用程序,它会产生很多线程

,每个都有这个能力来敲击服务器。


问题在于DLL类哪个单个工作得很好

实例遇到问题,因为每个版本的客户端线程

似乎都会进入DLL的SAME副本。


我读过的所有内容都告诉我在SyncLocks中包装处理

变量的DLL区域......但这不是我想要的...... DLL是不是

STATELESS所以每个新线程都需要拥有它自己独立的

dll及其变量的副本。


所以问题是如何实例化DLL(clas s)在线程中

确保它运行一个新的独特复制?


BTW,目前没有类的变量是公开的(虽然

Props / Meths必须是。)并且该课程尝试创建一个新的副本

使用...


将myDLLCls调暗为DLLLC

myDLLCls =新的DLLClass

但这不会在此主题中生成新副本。


帮助!


问候,

tob

Hi,

I have written a Class Library in VB.net which provides Props/Meths to a
caller to hide the uglinesses of a TCP message protocol between a Client
and a Server.

All this works just fine.

Now I am trying to develop a LOAD TESTER app which spawns lotso'' threads
each with this capability to bang the server.

The problerm is that the DLL class which worked just fine in a single
instance runs into problems because each version of the client-threads
seems to be reaching into the SAME copy of the DLL.

Everything I''ve read tells me to wrap the DLL areas that deal with
variables in SyncLocks... but this is NOT what I want... The DLL is NOT
STATELESS and so each new thread needs to have ITS OWN UNIQUE COPY of the
dll and its variables.

So the question is How Do I instantiate the DLL (class) in the thread to
ensure that it gets a NEW UNIQUE COPY running?

BTW, currently NONE of the Class''s variables are public (though the
Props/Meths must be.) And the class DOES attempt to create a new copy
using...

Dim myDLLCls as theDLLClass
myDLLCls = New theDLLClass
but this does NOT generate a NEW copy in this thread.

Help !

regards,
tob

推荐答案




" tony obrien" < tob _ @ _ sourcecode-inc.comwrote in message

news:Xn **************************** *****@130.81.64 .196 ...


"tony obrien" <tob_@_sourcecode-inc.comwrote in message
news:Xn*********************************@130.81.64 .196...




我写了一个类库在VB.net中,向一个

调用者提供Props / Meths,以隐藏客户端与服务器之间的TCP消息协议的uglinesses。


所有这一切都很好。


现在我正在尝试开发一个LOAD TESTER应用程序,它可以生成很多''''''''''''''''''''''''这个能够敲击服务器的能力。


问题在于,在单个

实例中运行良好的DLL类会遇到问题,因为每个版本的客户端线程

似乎正在进入DLL的SAME副本。


我读过的所有内容都告诉我要包装处理的DLL区域在SyncLocks中使用

变量...但这不是我想要的...... DLL不是

STATELESS所以每个新线程需要拥有自己独特的

dll及其变量的副本。
。 。 。
Hi,

I have written a Class Library in VB.net which provides Props/Meths to a
caller to hide the uglinesses of a TCP message protocol between a Client
and a Server.

All this works just fine.

Now I am trying to develop a LOAD TESTER app which spawns lotso'' threads
each with this capability to bang the server.

The problerm is that the DLL class which worked just fine in a single
instance runs into problems because each version of the client-threads
seems to be reaching into the SAME copy of the DLL.

Everything I''ve read tells me to wrap the DLL areas that deal with
variables in SyncLocks... but this is NOT what I want... The DLL is NOT
STATELESS and so each new thread needs to have ITS OWN UNIQUE COPY of the
dll and its variables.
. . .



这只是一个设计问题。如果每个客户都需要自己的数据,那么不要将数据放在共享范围内。为每个客户创建一个类,并将客户的状态数据放在该类的实例状态中。


David

That''s just a design problem. If each client needs its own data, don''t put
that data in shared scope. Create a class for each client to own, and place
that client''s state data in the instance state of that class.

David


" David Browne" < davidbaxterbrowne没有盆栽 me**@hotmail.com 写在

新闻:#G **** **********@TK2MSFTNGP02.phx.gbl:
"David Browne" <davidbaxterbrowne no potted me**@hotmail.comwrote in
news:#G**************@TK2MSFTNGP02.phx.gbl:

>


" tony奥布莱恩" < tob _ @ _ sourcecode-inc.comwrote in message

news:Xn **************************** *****@130.81.64 .196 ...
>

"tony obrien" <tob_@_sourcecode-inc.comwrote in message
news:Xn*********************************@130.81.64 .196...

>

我在VB中编写了一个类库.net为调用者提供道具/方法,以隐藏客户端和服务器之间的TCP消息协议的痕迹。

这一切都很好。 />
现在我正在尝试开发一个LOAD TESTER应用程序,该应用程序会生成很多线程,每个线程都有这个能力来敲击服务器。

问题在于DLL类在单个
实例中工作得很好会遇到问题,因为每个版本的客户端线程似乎都会进入DLL的SAME副本。

我所做的一切'read read告诉我在SyncLocks中包装处理
变量的DLL区域......但这不是我想要的...... DLL是不是无状态,因此每个新线程需要有它自己独一无二
复制dll及其复制品变量。
。 。 。
>Hi,

I have written a Class Library in VB.net which provides Props/Meths
to a caller to hide the uglinesses of a TCP message protocol between
a Client and a Server.

All this works just fine.

Now I am trying to develop a LOAD TESTER app which spawns lotso''
threads each with this capability to bang the server.

The problerm is that the DLL class which worked just fine in a single
instance runs into problems because each version of the
client-threads seems to be reaching into the SAME copy of the DLL.

Everything I''ve read tells me to wrap the DLL areas that deal with
variables in SyncLocks... but this is NOT what I want... The DLL is
NOT STATELESS and so each new thread needs to have ITS OWN UNIQUE
COPY of the dll and its variables.
. . .



这只是一个设计问题。如果每个客户都需要自己的数据,那么
不要将这些数据放在共享范围内。为每个客户创建一个类

拥有,并将该客户的状态数据置于该类的实例状态




大卫


That''s just a design problem. If each client needs its own data,
don''t put that data in shared scope. Create a class for each client
to own, and place that client''s state data in the instance state of
that class.

David



谢谢,大卫...


我不同意但看起来似乎反直觉的是,如果我要获得
,请获取DLL的SOURCE并将其(作为一个类)包含到项目中并使用
让每个新线程创建其副本那个类吧,每个线程WOULD

都有自己的,唯一的数据和变量副本......但是如果我创建

这个类分别作为DLL我不能得到一个独特的副本??


似乎你建议多线程DLL总是共享,并且
不能运行状态机。看起来像一个巨大的整体发展

的能力。


tob

Thanks, David...

I do not disagree BUT what seems counter intuitive is that if I were to
take the SOURCE of the DLL and include it (as a class) to the project and
let each new thread create its copy of that class it, each thread WOULD
have its own, unique copy of the data and variables... but if I create
the class separately as a DLL I CAN NOT get a unique copy??

It seems you are suggesting that Multithreaded DLLs are ALWAYS shared and
can not operate a state machines. Seems like a HUGE whole a development
capability.

tob





" tony obrien" < tob _ @ _ sourcecode-in.comwrote in message

news:Xn **************************** *****@130.81.64 .196 ...


"tony obrien" <tob_@_sourcecode-in.comwrote in message
news:Xn*********************************@130.81.64 .196...

" David Browne" < davidbaxterbrowne没有盆栽 me**@hotmail.com 写在

新闻:#G **** **********@TK2MSFTNGP02.phx.gbl:
"David Browne" <davidbaxterbrowne no potted me**@hotmail.comwrote in
news:#G**************@TK2MSFTNGP02.phx.gbl:

>>

" tony obrien" < tob _ @ _ sourcecode-inc.com写信息
新闻:Xn ******************************** *@130.81.6 4.196 ...
>>

"tony obrien" <tob_@_sourcecode-inc.comwrote in message
news:Xn*********************************@130.81.6 4.196...

>>

我在VB.net写了一个类库为调用者提供Props / Meths来隐藏客户端和服务器之间的TCP消息协议的uglinesses。

所有这些都可以正常工作。

现在我正在尝试开发一个LOAD TESTER应用程序,该应用程序可以生成很多线程,每个线程都有这个功能来敲击服务器。

问题在于DLL类只能工作单个
实例中遇到问题,因为每个版本的客户端线程似乎都会进入DLL的SAME副本。

我读过的所有内容告诉我在SyncLocks中包装处理变量的DLL区域......但这不是我想要的...... DLL是不是无状态,因此每个新线程都需要拥有ITS OWN UNIQUE
dll的COPY及其v ariables。
。 。 。
>>Hi,

I have written a Class Library in VB.net which provides Props/Meths
to a caller to hide the uglinesses of a TCP message protocol between
a Client and a Server.

All this works just fine.

Now I am trying to develop a LOAD TESTER app which spawns lotso''
threads each with this capability to bang the server.

The problerm is that the DLL class which worked just fine in a single
instance runs into problems because each version of the
client-threads seems to be reaching into the SAME copy of the DLL.

Everything I''ve read tells me to wrap the DLL areas that deal with
variables in SyncLocks... but this is NOT what I want... The DLL is
NOT STATELESS and so each new thread needs to have ITS OWN UNIQUE
COPY of the dll and its variables.
. . .


这只是一个设计问题。如果每个客户端都需要自己的数据,则不要将这些数据放在共享范围内。为每个客户创建一个类来拥有,并将该客户的状态数据放在
该类的实例状态中。

David



谢谢,大卫...


我不同意但是,如果我要这样做,那么反直觉就是

获取DLL的SOURCE并将其包含(作为一个类)到项目中并且

让每个新线程创建该类的副本吧,每个线程都要花费$>
有自己独特的数据和变量副本......但如果我创建

这个类作为DLL分别我不能得到一个独特的副本吗?


Thanks, David...

I do not disagree BUT what seems counter intuitive is that if I were to
take the SOURCE of the DLL and include it (as a class) to the project and
let each new thread create its copy of that class it, each thread WOULD
have its own, unique copy of the data and variables... but if I create
the class separately as a DLL I CAN NOT get a unique copy??



是的,你可以。有嵌套的范围,您可以在其中声明状态。你在
谈论的是最外层的范围:类范围。您定义的每个类

都有一个类范围(也就是全局,共享,静态)。在此范围内声明的变量,或者可以从此范围内的变量中获取的变量在App域中的所有

呼叫者之间共享。


为每个客户创建的类型的实例变量声明或可以获得的变量

不会被共享。

Yes you can. There are nested scopes in which you can declare state. You
are talking about the outermost scope: class scope. Each class you define
has a class scope (aka global, shared, static). Variables declared in this
scope, or reachable from a variable in this scope are shared among all
callers in the App Domain.

Variables declared or reachable from instance variables of a type created
separately for each client won''t be shared.


似乎您建议多线程DLL始终共享,并且
无法运行状态机。看起来像一个巨大的整体发展

的能力。
It seems you are suggesting that Multithreaded DLLs are ALWAYS shared and
can not operate a state machines. Seems like a HUGE whole a development
capability.



一点也不。你可以分享和分享你想要的状态。


David

No not at all. You can have any mix of sharing and separation of state you
want.

David

这篇关于DLL的唯一副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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