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 10 999
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" <De****@discussions.microsoft.com> schrieb: 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
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/>
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: 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" <De****@discussions.microsoft.com> wrote 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.
Perhaps you could supply a more complete example, something small that
can be pasted into a new form, to see what it is you say isn't working.
This statement of yours is in error.... If I do a myobject.Dispose, I can no longer assign the variable myobject to another bitmap.
You don't assign variables to bitmaps, you assign bitmaps to variables. Using
dispose on the bitmap, after you are done with it, is the proper course of action.
LFS
Larry,
This is done in a long thread before unluckily Dennis started a new thread
and than you get this kind of starting every discussion new again.
The problem is that Dennis has its bitmap globaly and want to keep the
bitmap, what he wants is and I don't know it that works.
\\\
dim mybitmap as bitmap
public sub whatever
if Not mybitmap Is Nothing then
mybitmap.dispose
end if
mybitmap = New bitmap(.....)
end sub
///
Cor
"Cor Ligthert" <no************@planet.nl> wrote This is done in a long thread before unluckily Dennis started a new thread and than you get this kind of starting every discussion new again.
Thank you Cor, as busy as I have been, I'll probably have to lurk a while
to watch for new threads, instead of jumping in the middle of finished
discussions....
:-)
LFS
Thanks Cor for clarifying my problem. That's excatly what I wnat to do.
However, when executing the code, I get an error on the line mybitmap = new
bitmap(...) saying "Invalid Parameter Used" because, I think, when I use the
mybitmap.dispose, it disposes not only the bitmap but destroys the variable
mybitmap.
"Cor Ligthert" wrote: Larry,
This is done in a long thread before unluckily Dennis started a new thread and than you get this kind of starting every discussion new again.
The problem is that Dennis has its bitmap globaly and want to keep the bitmap, what he wants is and I don't know it that works.
\\\ dim mybitmap as bitmap public sub whatever if Not mybitmap Is Nothing then mybitmap.dispose end if mybitmap = New bitmap(.....) end sub ///
Cor
Dennis,
This I could do endless
\\\
Private mybitmap As Bitmap
Private Sub Button1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
If Not mybitmap Is Nothing Then
mybitmap.Dispose()
End If
mybitmap = New Bitmap("c:\test1\mybitmap.bmp")
End Sub
///
So what is in your parameter. http://msdn.microsoft.com/library/de...sctortopic.asp
We only saw that it was probably a function returning something
Cor
"Dennis" <De****@discussions.microsoft.com> Thanks Cor for clarifying my problem. That's excatly what I wnat to do. However, when executing the code, I get an error on the line mybitmap = new bitmap(...) saying "Invalid Parameter Used" because, I think, when I use the mybitmap.dispose, it disposes not only the bitmap but destroys the variable mybitmap.
"Cor Ligthert" wrote:
Larry,
This is done in a long thread before unluckily Dennis started a new thread and than you get this kind of starting every discussion new again.
The problem is that Dennis has its bitmap globaly and want to keep the bitmap, what he wants is and I don't know it that works.
\\\ dim mybitmap as bitmap public sub whatever if Not mybitmap Is Nothing then mybitmap.dispose end if mybitmap = New bitmap(.....) end sub ///
Cor
"Dennis" <De****@discussions.microsoft.com> schrieb: However, when executing the code, I get an error on the line mybitmap = new bitmap(...) saying "Invalid Parameter Used" because, I think, when I use the mybitmap.dispose, it disposes not only the bitmap but destroys the variable mybitmap.
Please post the complete code calling the 'Bitmap' constructor.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thanks Cor, you've helped solve my problem. What was happening was that I
had code similiar to yours but had a test for mybitmap is nothing before
resetting it to a different bit map. Thanks..this has been driving me nuts
for sometime now.
Private mybitmap As Bitmap
Private Sub Button1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
If Not mybitmap Is Nothing Then
mybitmap.Dispose()
End If
If mybitmap Is Nothing then mybitmap = New Bitmap("c:\test1 _
\mybitmap.bmp")
......... Use mybitMap for something (got errorhere)
End Sub
What apparently happens is that when you do a mybitmap.dispose, it doesn't
set the variable mybitmap to Nothing so next time I try to set mybitmap to a
new bitmap based on it being nothing, it doesn't get set because mybitmap is
not nothing...not sure what it is but it's sure not nothing.
"Cor Ligthert" wrote: Dennis,
This I could do endless \\\ Private mybitmap As Bitmap Private Sub Button1_Click(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click If Not mybitmap Is Nothing Then mybitmap.Dispose() End If mybitmap = New Bitmap("c:\test1\mybitmap.bmp") End Sub ///
So what is in your parameter. http://msdn.microsoft.com/library/de...sctortopic.asp
We only saw that it was probably a function returning something
Cor
"Dennis" <De****@discussions.microsoft.com>
Thanks Cor for clarifying my problem. That's excatly what I wnat to do. However, when executing the code, I get an error on the line mybitmap = new bitmap(...) saying "Invalid Parameter Used" because, I think, when I use the mybitmap.dispose, it disposes not only the bitmap but destroys the variable mybitmap.
"Cor Ligthert" wrote:
Larry,
This is done in a long thread before unluckily Dennis started a new thread and than you get this kind of starting every discussion new again.
The problem is that Dennis has its bitmap globaly and want to keep the bitmap, what he wants is and I don't know it that works.
\\\ dim mybitmap as bitmap public sub whatever if Not mybitmap Is Nothing then mybitmap.dispose end if mybitmap = New bitmap(.....) end sub ///
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Egghead |
last post by:
Hi all,
I'm just wondering that is any way to dispose all objects when my app is
shut down? I mean I can use for.. next loop to unload all loaded form when I
shut down my app.
Thank you,
...
|
by: Chris Capel |
last post by:
I've heard a lot of talk on the forum about memory managment in .NET and
disposing things, finalizing them, garbage collection, etc. My question is
which managed types need to be disposed after...
|
by: MC D |
last post by:
Question:
If I have a class which has a property which is a collection of widget
objects (an arrayList of widgets), and both the containter class and the
widget class implement the IDisposable...
|
by: Mathias L. |
last post by:
I have two questions for which I couldnt find answer:
If I programaticaly close DialogForm (calling Close()), is it enough or do I
have to dispose it as MS.NET help says?
Also, in overriden...
|
by: sunitabalakrishna |
last post by:
Hi,
Could someone explain me if I need to implement the Dispose pattern on
managed objects that hold objects which have longer life or is a
singleton?
Example -
Class A holds Class Global...
|
by: Mariusz |
last post by:
Hello,
I have question regarding disposing objects in aspx/cs pages. If I create
some objects/Arrays/ListArrays in pageLoad do I have to dispose them (by
assigning the null value for objects that...
|
by: Gman |
last post by:
Hi,
Objective:
Draw a grid on a bitmap and set this as a panel's image. (Rather than
draw the grid directly on the panel and redraw repeatedly in the paint
event.)
Problem:
It works fine....
|
by: Adam Right |
last post by:
Hi,
I am developing a financial application and you know that there are huge
amount of data in these similar aplications. I have a MDIChild form and the
other forms are opened in this form. For...
|
by: Rob |
last post by:
Hi all,
I wrote myself a little function to do my own housekeeping, I can call
it by using
Dispose(object)
Within this function there's a select case statement which will then,
based on...
|
by: Jerry Spence1 |
last post by:
I'm rather confused as to whether something should be disposed of, or not.
What is the general rule? How can you be sure of doing the right thing? I've
heard about disposing unmanaged resources but...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |