处置对象-AGAIN [英] Disposing of Objects -AGAIN

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

问题描述

我不认为我在前一个问题中明确说明了我的问题,所以让我再试一次

。我有以下内容:


作为位图的私人myobject


myobject = mybitmap(从屏幕的一部分创建)


我如何处理mybitmap对象的实例但保留myobject让我

可以再次使用它:


myobject = mysecondbitmap


如果我做了myobject.Dispose,我就不能再将变量myobject分配给另一个位图了。
另一个位图。如果我将myobject设置为空,mybitmap

和mysecondbitmap的瞬间仍然存在,必须等待GC处理




-

休斯顿的丹尼斯

I don''t think I clearly stated my problem in my prior question so let me try
again. I have the following:

Private myobject as Bitmap

myobject = mybitmap (created from a part of the screen)

How do I dispose of the instance of mybitmap object yet retain myobject so I
can use it again like:

myobject = mysecondbitmap

If I do a myobject.Dispose, I can no longer assign the variable myobject to
another bitmap. If I set myobject to nothing, the instantance of mybitmap
and mysecondbitmap are still existing and have to wait for the GC to dispose
of them.

--
Dennis in Houston

推荐答案




看看Bitmap.clone。

http://msdn.microsoft.com/library/de...clonetopic.asp


Ken

-----------------

Dennis <德**** @ discussions.microsoft.com>在消息中写道

新闻:0D ********************************** @ microsof t.com ...

我不认为我在前一个问题中明确说明了我的问题所以让我再试一次

。我有以下内容:


作为位图的私人myobject


myobject = mybitmap(从屏幕的一部分创建)


我如何处理mybitmap对象的实例但保留myobject让我

可以再次使用它:


myobject = mysecondbitmap


如果我做了myobject.Dispose,我就不能再将变量myobject分配给另一个位图了。
另一个位图。如果我将myobject设置为空,mybitmap

和mysecondbitmap的瞬间仍然存在,必须等待GC处理




-

Dennis in Houston
Hi,

Take a look at Bitmap.clone.

http://msdn.microsoft.com/library/de...clonetopic.asp

Ken
-----------------
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
I don''t think I clearly stated my problem in my prior question so let me try
again. I have the following:

Private myobject as Bitmap

myobject = mybitmap (created from a part of the screen)

How do I dispose of the instance of mybitmap object yet retain myobject so I
can use it again like:

myobject = mysecondbitmap

If I do a myobject.Dispose, I can no longer assign the variable myobject to
another bitmap. If I set myobject to nothing, the instantance of mybitmap
and mysecondbitmap are still existing and have to wait for the GC to dispose
of them.

--
Dennis in Houston


" Dennis" <德**** @ discussions.microsoft.com> schrieb:
"Dennis" <De****@discussions.microsoft.com> schrieb:
我不认为我在先前的问题中明确说明了我的问题所以让我再次尝试
。我有以下内容:

私人myobject作为位图

myobject = mybitmap(从屏幕的一部分创建)

如何处理mybitmap对象的实例还保留了myobject所以
我可以再次使用它:

myobject = mysecondbitmap
I don''t think I clearly stated my problem in my prior question so let me
try
again. I have the following:

Private myobject as Bitmap

myobject = mybitmap (created from a part of the screen)

How do I dispose of the instance of mybitmap object yet retain myobject so
I
can use it again like:

myobject = mysecondbitmap



$ b $嗯......我不明白为什么你要处理这个实例如果你仍然需要它来支付它......


-

MS Herfried K. Wagner

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

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



Mhm... I don''t understand why you want to dispose the instance if you still
need it...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


我想处理我完成后创建的第一个位图使用它

并设置变量myObject来引用不同的位图,这样在下一次调用我的函数时,它将使用不同的位图。我不能将

变量作为参数传递,因为我正在使用MouseEvents。


" Dennis"写道:
I want to dispose of the first bitmap I created after I''ve finished using it
and set the variable myObject to reference a different bitmap so on the next
call to my functions, it will use the different bitmap. I can''t pass the
variable as a parameter because I am working with MouseEvents.

"Dennis" wrote:
我不认为我在前一个问题中明确说明了我的问题所以让我再试一次
。我有以下内容:

私人myobject作为位图

myobject = mybitmap(从屏幕的一部分创建)

如何处理mybitmap对象的实例还保留了myobject,所以我可以再次使用它:

myobject = mysecondbitmap

如果我做myobject.Dispose,我就不能将变量myobject更长时间分配给另一个位图。如果我将myobject设置为空,mybitmap
和mysecondbitmap的瞬间仍然存在,并且必须等待GC处理它们。

-
休斯顿的丹尼斯
I don''t think I clearly stated my problem in my prior question so let me try
again. I have the following:

Private myobject as Bitmap

myobject = mybitmap (created from a part of the screen)

How do I dispose of the instance of mybitmap object yet retain myobject so I
can use it again like:

myobject = mysecondbitmap

If I do a myobject.Dispose, I can no longer assign the variable myobject to
another bitmap. If I set myobject to nothing, the instantance of mybitmap
and mysecondbitmap are still existing and have to wait for the GC to dispose
of them.

--
Dennis in Houston



这篇关于处置对象-AGAIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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