Created
May 27, 2011 09:49
-
-
Save philipstears/994963 to your computer and use it in GitHub Desktop.
Release and Swap a COM reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Extension()> | |
Public Sub ReleaseAndExchange(Of T As Class)(ByRef oldComObject As T, ByVal newComObject As T) | |
If oldComObject IsNot Nothing Then | |
Marshal.ReleaseComObject(oldComObject) | |
End If | |
oldComObject = newComObject | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment