|
Are you sure the process was being killed? This sounds like it might have been a web app and IIS would have been the process in that case, so you'd be relying on the GC to come along and help you.
File handles, open sockets and properly registered graphical resources are definitely released when a process ends under Windows.
Obviously, it's still good practice to close your resources manually because you don't want to make the user close your application to free them!
|
|
|
|
|
BobJanova wrote: Obviously, it's still good practice to close your resources manually because you
don't want to make the user close your application to free them!
It is, it was and always will be. Unless you are a member of the reformed Java religion, who do not believe in managing memory and resources.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
Relying on the GC to clean up after classes that implements IDisposable may be dangerous - in some cases such a class may never be garbage collected and thus in practice lead to memory leaks.
Consider a class that e.g., when instantiated, subscribes to an event from .NET's SystemEvents class (a GUI application might e.g. subscribe to UserPreferenceChanged). Because these events are static, the delegate have a reference to the class that lasts for the entire lifetime of the application, i.e. it will prevent the class from being GC'ed until it unsubscribes from the event. I.e. the user of the class will have to tell it when it no longer needs to subscribe to such an event - the obvious way to do that is by calling Dispose.
Now, you could argue that not all classes that implements Dispose suffer from this, but how would you know (and know that a future version of the class wouldn't require it either)? And should you know - is it not the purpose of encapsulation to ensure that you don't have to know about implementation details like this?
Due to this, in my opinion is should not only be best practice, but required that you call Dispose on a class that implements IDisposable.
|
|
|
|
|
Re: 1) - you're not going to invite SQL injection with a method. You'll invite injection from user entry or some such thing. I guess I'm suggesting this method is safe IF I can assume some protection is in place before it is invoked.
|
|
|
|
|
At least he made it a Private function, that is one good thing!
|
|
|
|
|
Maybe the Republicans are correct when they say "Outsourcing is good for the economy." It keeps all of us employed rewriting all that crap code!
|
|
|
|
|
Return oRs
oRs.Dispose()
oDAdapt.Dispose()
the dispose never gets hit because the return will exit the function
|
|
|
|
|
Someone may have already pointed this out, I've not read all the replies yet, but the first thing I noticed is that the lines that dispose the dataset and dataadapter will never execute.
|
|
|
|
|
Indeed. That is one of the many things wrong with this code.
|
|
|
|
|
There is a few wrong stuff, but main error is that code is written on an bastardly stupid VB!
|
|
|
|
|
A screenshot from my laptop early today..
<a href="https://picasaweb.google.com/lh/photo/De0HCAngTHWVhc6HEy3NJNMTjNZETYmyPJy0liipFm0?feat=directlink">https://picasaweb.google.com/lh/photo/De0HCAngTHWVhc6HEy3NJNMTjNZETYmyPJy0liipFm0?feat=directlink</a>[<a href="https://picasaweb.google.com/lh/photo/De0HCAngTHWVhc6HEy3NJNMTjNZETYmyPJy0liipFm0?feat=directlink" target="_blank" title="New Window">^</a>]
-- modified 27-Jul-12 5:14am.
|
|
|
|
|
|
Edited it in latest Chrome. Doesn't show up too good with that either.
|
|
|
|
|
Just copy the link direct from the address bar, and paste it into the page.
One of four things will happen:
1) It will automatically become linkified (mine did, and about 90% or more do)
2) It will be pasted, and an option will appear at thr right hand side - select "as is" and then highlight the link before pressing the [^] widget.
3) It will be pasted and no option will appear but there is a good chance it will be surrounded by pare tags, selected to VB. Swear. remove the pre tags, and treat as above.
4) It will be pasted, not option will appear and your browser will freeze up. Swear lots. Wait. Wait some more. Swear some more. Wait. Eventually it comes back to life and you can continue with 2 or 3 above.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
What Windows did to me (as shown in the link) was much better. I would rather take down the link. 
|
|
|
|
|
Sorry Griff, replied on the wrong part of the thread..
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I've done it myself from time to time...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Where's the weird?
Updating the app that's responsible for the updates might sound a bit strange at first, but it makes perfect sense; it's merely an app, and from time to time, it needs an update.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Dude MVVM has a different meaning!
public LoginControl()
{
InitializeComponent();
passwordTextBox.Focus();
LoginViewModel loginViewModel = new LoginViewModel(new Model.UserCredential { Username = Environment.UserName, Domain = Environment.UserDomainName });
((LoginCommand)loginViewModel.LoginCommand).LoginResultValueChanged += new LoginCommand.LoginResultChangedHandler(LoginCommand_LoginResultValueChanged);
loginViewModel.LoginRemembered += new LoginViewModel.LoginRememberedHandler(loginViewModel_LoginRemembered);
this.DataContext = loginViewModel;
}
public bool LoginAsDifferentUser
{
get { return _isLoginAsDifferentUser; }
set
{
_isLoginAsDifferentUser = value;
if (this.DataContext != null && _isLoginAsDifferentUser)
{
(this.DataContext as LoginViewModel).ClearLoginCredential();
}
}
}
|
|
|
|
|
|
Blech!
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
Darn!! I almost thought you'd say: DLL Hell
|
|
|
|
|
ExcellentOrg wrote: DLL Hell
Well, that works as well!
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
[begin rant]
So, I've been doing some integrations between our company Oracle E-Business Suite ERP and a website from a company that has been recently acquired by us.
Our ERP exposes a webservice that our main website and the newly acquired company's website need to call, and sync clients, orders, products, etc (the two websites are e-commerce).
So, I had to make a module for the new company website, and have that module call the ERP webservice with the needed data. The new company website is PHP. Now, I also had to output some data in some tables that would show up as a webpage full of logs, when I found a PHP bug (I guess it's a bug, cause if it's not, then it's elephanting plain weird). So let's say we have:
[outputting some unrelated table stuff]
[...].
$result .= '<td>'.date('d-m-Y g:i A', strtotime($header->getCreatedTimestamp())).'</td>';
$result .= '<td>'.(intval($header->getPlacedTimestamp() != 0)) ? 'Yes' : 'No' .'</td>';
$result .= '<td>'.(intval($header->getPlacedTimestamp() != 0)) ? $header->getPlacedTimestamp() : '-' .'</td>';
$result .= '<td>'.$header->getSupplierName().'</td>';
[outputting other unrelated table stuff]
[...].
So, imagine my surprise when the result of the two ternaries gets placed BEFORE THE GODDAMNED TABLE!!! I mean, the output is:
[Ternaries result]
[table with my other data, no result from the two ternaries whatsoever, and the td's are simply missing]
And the fix was simply to place the ternary result into two variables, and output those (I guess those two get somehow evaluated and executed before the other code, or I just don't know):
[outputting some unrelated table stuff]
[...].$is_placed = (intval($header->getPlacedTimestamp() != 0)) ? 'Yes' : 'No';
$placed_ts = (intval($header->getPlacedTimestamp() != 0)) ? $header->getPlacedTimestamp() : '-';
$result .= '<td>'.date('d-m-Y g:i A', strtotime($header->getCreatedTimestamp())).'</td>';
$result .= '<td>'. $is_placed .'</td>';
$result .= '<td>'. $placed_ts .'</td>';
$result .= '<td>'.$header->getSupplierName().'</td>';
[outputting other unrelated table stuff]
[...].
Oh, and I also had to output the HTML table from PHP code (as a requirement, I had to follow their...'guidelines', which enforce this )
[end rant]
Edit: Sorry, I just had to get this thing off my chest. I think I'll go shoot myself now. I miss my Android project (looking back, maybe it was simpler to just delay its completion forever, instead of ending it on time...Oh, blissful ignorance )
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
This is caused by a piece of PHP weirdness combined with a browser getting confused about mismatched tags.
The PHP weirdness is that the ternary is a weak binding. So
$var = $bool ? 1 : 0 . ' bowls of petunias';
... will set $var to either (numeric) 1 or (string) "0 bowls of petunias". This isn't wrong, per se, but it is surprising if you come from a language where the ternary is a strong binding. In PHP you must do
$var = ($bool ? 1 : 0) . ' bowls of petunias';
As a result of that, you're outputting markup with mismatched <td>/</td> tags, if the ternaries pick the first option. If that inside a nested table, most browsers will just give up on trying to work out what's going on and draw the contents of the mismatched cells before the inner table.
|
|
|
|