<p>X Windows has special processes called Window Managers that manage the layout of windows and decorations like their title bar, control buttons etc. Such processes use an X Windows API to detect events related to windows sizes and positions.</p>

<p>Are there any consistent ways for writing such processes for Microsoft Windows or Mac OS/X?</p>

<p>I know that in general these systems are less flexible but I'm looking for something that will use public APIs and not undocumented hacks.</p>

[{'answer_id': 42434, 'author': 'David Basarab', 'author_id': 2469, 'author_profile': 'https://Stackoverflow.com/users/2469', 'pm_score': 2, 'selected': False, 'text': '<p>Garbage collection will gather up the first new when it is run.</p>\n\n<p>Only the second one you purposely dispose in the Finally block.  The first one will be disposed of the next time the garbage collection is run.</p>\n\n<p>I do not think this is a good idea.  If the first command is not closed correctly it is possible you would have an open connection to the database and it will not be disposed.</p>\n\n<p>A better way would be to dispose the first command after you are done using it, and then to reuse it.</p>\n'}, {'answer_id': 42436, 'author': 'Campbell', 'author_id': 942, 'author_profile': 'https://Stackoverflow.com/users/942', 'pm_score': 0, 'selected': False, 'text': "<p>No, the garbage collector will find the old version of mySql and deallocate it in due course.</p>\n\n<p>The garbage collector should pick up anything that's been dereferenced as long as it hasn't been moved into the Large Object Heap.</p>\n"}, {'answer_id': 42445, 'author': 'swilliams', 'author_id': 736, 'author_profile': 'https://Stackoverflow.com/users/736', 'pm_score': 4, 'selected': True, 'text': '<p>Just to extend what Longhorn213 said, here\'s the code for it:</p>\n\n<pre><code>Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)\n  \' do stuff\'\nEnd Using\n\nUsing mysql as SqlCommand = new SqlCommand(otherSql, cnInput)\n  \' do other stuff\'\nEnd Using\n</code></pre>\n\n<p>(edit) Just as an FYI, using automatically wraps the block of code around a try/finally that calls the Dispose method on the variable it is created with. Thus, it\'s an easy way to ensure your resource is released. <a href="http://msdn.microsoft.com/en-us/library/htd05whh(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/htd05whh(VS.80).aspx</a></p>\n'}, {'answer_id': 42453, 'author': 'Rob Walker', 'author_id': 3631, 'author_profile': 'https://Stackoverflow.com/users/3631', 'pm_score': 0, 'selected': False, 'text': '<p>Whilst garbage collection will clean up after you <em>eventually</em> the dispose pattern is there to help the system release any resources associated with the object sooner,  So you should call dispose once you are done with the object before re-assigning to it.</p>\n'}, {'answer_id': 42454, 'author': 'Domenic', 'author_id': 3191, 'author_profile': 'https://Stackoverflow.com/users/3191', 'pm_score': 1, 'selected': False, 'text': '<p>Uh, to all those people saying "it\'s OK, don\'t worry about it, the GC will handle it..." the whole <em>point</em> of the <code>Dispose</code> pattern is to handle those resources the GC <em>can\'t</em> dispose of. So if an object has a <code>Dispose</code> method, you\'d better call it when you\'re done with it!</p>\n\n<p>In summary, Longhorn213 is correct, listen to him.</p>\n'}, {'answer_id': 42501, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 1, 'selected': False, 'text': '<p>One thing I never worked out - If I have a class implementing <code>IDisposable</code>, but I never actually dispose it myself, I just leave it hanging around for the GC, will the GC actually call <code>Dispose</code> for me?</p>\n'}, {'answer_id': 43118, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 0, 'selected': False, 'text': "<p>Be careful.  If you have to do a lot of these in a loop it can be slow.  It's much better to just update the .CommandText property of the same command, like this (also, you can clean up the syntax a little):</p>\n\n<pre><code>Using mysql as New SqlCommand(sSql, cnInput)\n  ' do stuff'\n\n    mySql.CommandText = otherSql\n\n   'do other stuff'\nEnd Using\n</code></pre>\n\n<p>Of course, that only works if the first command is no longer active.  If you're still in the middle of going through a datareader then you better create a new command.</p>\n"}]
['https://Stackoverflow.com/questions/42428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1476/']