|
You enumerate through your objects and call Dispose on them.
Seriously, your question about shutting down is not answerable because we have no idea what your code is doing, how the app is written, what your code does in the event of a shutdown request, ...
What is the main purpose of the app and how is the engine that provides this functionality written??
|
|
|
|
|
Some objects have a .Dispose method which you can call.
Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced.
For example:
myObj.dispose() ' only if supported
myObj = nothing ' indicate that the object is no longer referenced
|
|
|
|
|
David Mujica wrote: Also, you can set the object to "nothing", which will indicate to the garbage collector that the object is no longer referenced.
that is completely irrelevant when the app is about to shut down as the OP stated.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
When an app shuts down, the Operating System recovers memory allotted to that app. So you don't have to worry about it. Modern operating systems (including Windows) are pre-emptive, i.e., they don't need the permission or co-operation of the applications to recover memory.
|
|
|
|
|
Also, all .Net finalizers are run while the application shuts down.
|
|
|
|
|
Not necessarily. The runtime host can decide whether to run finalizers or not during application shutdown.
|
|
|
|
|
Hi all...
I have created a program that checks system's processor's ID and some registry keys before starting. After that it works in background.
The problem is here that when the program is in execution and I am trying to shutdown my system then my system is not shutting down and the problem is that Windows is unable to kill my program's execution forcefully or something like that. How to solve this problem, suggest me.
Thanks.
Gagan
|
|
|
|
|
did you do anything special to get that?
is your app windowless?
maybe SystemEvents.SessionEnding could help you out.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Well, I am getting processor's ID by importing System.management namespace and bye creating objects of ManagementObject and ManagementObjectSearcher and getting registry keys by using my.computer.registry class.
Could you explain me your solution or do you have any piece of code?
Thanks.
Gagan
|
|
|
|
|
use Google to research; you might find things like this[^].
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
hi man,
sounds like you have override the OnClosing / OnClose functions. And in there you set the EventArgs.Cancel to true?!?
if you do this you need to check the CancelEventArguments for a CloseReason.
in that case cast the CancelEventArgs to FormClosingEventArgs and check the Property CloseReason for CloseReason.WindowsShutdow,etc.. before setting args.Cancel to true.
hope i could help
bless
|
|
|
|
|
can you help me how to use DTPicker in visual basic.
my system is reservation of lcd. i dont know the codes when im going to assign a date and time. for example im going to reserve an lcd for tomorrow and time. what codes will i use?? using DTPicker.
|
|
|
|
|
You really seem to be lost. The user would choose the dates as the next day. Now, to get that date in your code, you can use the value or text property of the datetimepicker.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hello,
I want to create a folder on vista machine using vb.net or C#. and make it share. and one more task is make it full access control for network users.
can any one suggest how i do this.
Thanks
~Khatri Mitesh
khatrimitesh@hotmail.com
Bikaner (Rajasthan)
INDIA
http://www.youtube.com/watch?v=-oJaaPCrk3Q
|
|
|
|
|
Look into DirectorySecurity class. That will help you. I guess it has a setaccesscontrol method which might be of your interest.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
eg in msdn
Private Sub LoadNewPict()
' You should replace the bold image
' in the sample below with an icon of your own choosing.
PictureBox1.Image = Image.FromFile _
(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.Personal) _
& "\Image.gif")
End Sub
but when i set up a smart machine project, "image.fromfile" is not supported
Is there any other method to do it?
thanks a lot~
|
|
|
|
|
Image.FromFile is the only method I know of to load a bitmap from a file. Do you have the right dlls imported ? System.Drawing, I believe.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
There are at least three ways of getting an image from a file:
- Image.FromFile()
- Image.FromStream()
- Bitmap(filename) constructor
AFAIK the third one exists on all platforms.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi All,
I am facing a weird kinda problem. Can't figure the solution. Here is the problem.
I have a string "FLAMES". This is a fixed string. I want to start counting the string characters till it reaches the value of an integer 'n' say the value of n = 7.
So what I is want is the code to start counting from F,L,A,M,E,S now at n = 6 the string finishes, so n = 7 will be "F". Now at the last count of n whatever alphabet is there it should get scrapped off. In this case "F" gets scrapped off. The reamining string is "LAMES".
Then restart the count from "L" till n = 7 and this time the alphabet that gets scrapped will be "A", the remaining string is "LMES"
Again restart the count from next character which in this case is "M".
Repeat this procedure untill there is only one alphabet remaining in "FLAMES". In this case of n = 7 it should be "E"
Can anybody help in this? I'm really stuck at this.
Thanks in advance for any help.
Manik
|
|
|
|
|
Sounds like some incredibly simple homework to me. We're not going to do it for you, you have to try yourself. It's set so you can learn, not because the world needs this program to exist. So, what have you tried ? Think about the task, think about how to logically break down the steps you want to take. If you're stuck when you bothered to try yourself, you might post code here and ask a SPECIFIC question.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Here is a tip...
SubString
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
and the Second tip is ...
.... using a loop
|
|
|
|
|
Hey guys okay so im trying to do a Bubble Sort dealing with an array of data that is being loaded at form load from a text file
But right now i keep getting an error everytime it is being executed. I keep getting this error: Index was outside the bounds
of the array!
But i cant see where I am gng wrong?
This is what i am trying to do: my array contains values like this: "C2 H2 SA D4 D2 DA SK S9 S4 HA HQ HK" IT CONTAINS 52 values
all together
Then this is what im trying to sort when the user clicks arrange button: "C2 D2 D4 H2 HQ HK HA S4 S9 SK SA"
PLEASE HELP!!!!!!!!!
Private Sub btnArrange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArrange.Click
'*************************************************
'this sub will sort the players cards in increasing
'order using a bubble sort
Dim Last, i As Integer
Dim temp As String
Dim ExchangeMade As Boolean
lblPlayer1.Text = ""
lblPlayer2.Text = ""
lblPlayer3.Text = ""
lblPlayer4.Text = ""
Last = ShuffleCards.cards2.Length - 1
Do
ExchangeMade = False
For i = 0 To Last
If ShuffleCards.cards2(i) > ShuffleCards.cards2(i + 1) Then
'exchange values
temp = ShuffleCards.cards2(i)
ShuffleCards.cards2(i) = ShuffleCards.cards2(i + 1) '*****THIS IS WHERE THE ERROR OCCURS******
ShuffleCards.cards2(i + 1) = temp
ExchangeMade = True
End If
Next i
Last = Last - 1 'decrement length
Loop Until (Not (ExchangeMade = True)) Or (Last = 0)
'DISPLAY SORTED DATA IN EACH LABEL
For i = 0 To ShuffleCards.cards2.Length - 1
lblPlayer1.Text += ShuffleCards.cards2(i)
lblPlayer2.Text += ShuffleCards.cards2(i + 1)
lblPlayer3.Text += ShuffleCards.cards2(i + 2)
lblPlayer4.Text += ShuffleCards.cards2(i + 3)
Next
End Sub
|
|
|
|
|
PAguilar09 wrote: If ShuffleCards.cards2(i) > ShuffleCards.cards2(i + 1) Then
If i counts up to the biggest possible value, when it gets there, is i+1 still inside the array, or not ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
well i set breakpoints and saw that as the loop runs my arraylength is 51 since the index value = 51 because there are 52 values total
During the loop i also saw that the values are not being sorted in ascending order it takes the first value in teh array
and tests to see if its in order if not then it should swap.
I am so lost at why this sort wont work??????
|
|
|
|